annotate src/mactoolbox.c @ 80726:abf87febdee3 EMACS_PRETEST_22_2_90

Regenerate.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 15 Aug 2008 16:33:37 +0000
parents 557c72d63824
children 1f63840526a9 3760da9fe15e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1 /* Functions for GUI implemented with (HI)Toolbox on the Mac OS.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2 Copyright (C) 2000, 2001, 2002, 2003, 2004,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5 This file is part of GNU Emacs.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6
cb749087dcc9 New file.
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
cb749087dcc9 New file.
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
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
10 any later version.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
11
cb749087dcc9 New file.
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,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
15 GNU General Public License for more details.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
16
cb749087dcc9 New file.
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
cb749087dcc9 New file.
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
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
20 Boston, MA 02110-1301, USA. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
21
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
22 #include <config.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
23
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
24 #include <stdio.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
25
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
26 #include "lisp.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
27 #include "blockinput.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
28
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
29 #include "macterm.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
30
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
31 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
32 #include <Quickdraw.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
33 #include <ToolUtils.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
34 #include <Sound.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
35 #include <Events.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
36 #include <Script.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
37 #include <Resources.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
38 #include <Fonts.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
39 #include <TextUtils.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
40 #include <LowMem.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
41 #include <Controls.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
42 #include <Windows.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
43 #include <Displays.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
44 #if defined (__MRC__) || (__MSL__ >= 0x6000)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
45 #include <ControlDefinitions.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
46 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
47
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
48 #if __profile__
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
49 #include <profiler.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
50 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
51 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
52
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
53 #include "charset.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
54 #include "coding.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
55 #include "frame.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
56 #include "dispextern.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
57 #include "fontset.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
58 #include "termhooks.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
59 #include "buffer.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
60 #include "window.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
61 #include "keyboard.h"
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
62
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
63 #include <sys/param.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
64
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
65 #ifndef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
66 #include <alloca.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
67 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
68
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
69
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
70 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
71 General
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
72 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
73
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
74 /* The difference in pixels between the top left corner of the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
75 Emacs window (including possible window manager decorations)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
76 and FRAME_MAC_WINDOW (f). */
cb749087dcc9 New file.
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)
cb749087dcc9 New file.
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)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
79
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
80 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
81
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
82 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
83 mac_alert_sound_play ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
84 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
85 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
86 AlertSoundPlay ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
87 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
88 SysBeep (1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
89 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
90 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
91
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
92
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
93 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
94 Application
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
95 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
96
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
97 extern struct frame *mac_focus_frame P_ ((struct mac_display_info *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
98 extern void do_keystroke P_ ((EventKind, unsigned char, UInt32, UInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
99 unsigned long, struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
100 extern UInt32 mac_mapped_modifiers P_ ((UInt32, UInt32));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
101 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
102 extern int mac_to_emacs_modifiers P_ ((UInt32, UInt32));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
103 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
104 extern int mac_to_emacs_modifiers P_ ((EventModifiers, EventModifiers));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
105 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
106
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
107 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
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
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
109 used for passing an input event to the function back from
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
110 Carbon/Apple event handlers. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
111 static struct input_event *read_socket_inev = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
112
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
113 extern const unsigned char keycode_to_xkeysym_table[];
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
114 extern EMACS_INT extra_keyboard_modifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
115
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
116 extern Lisp_Object Qhi_command;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
117 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
118 static TSMDocumentID tsm_document_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
119 extern Lisp_Object Qtext_input;
cb749087dcc9 New file.
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>
parents: 80517
diff changeset
121 extern Lisp_Object Vmac_ts_active_input_overlay, Vmac_ts_active_input_buf;
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
122 extern Lisp_Object Qbefore_string;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
123 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
124
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
125 static int mac_event_to_emacs_modifiers P_ ((EventRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
126 static OSStatus install_menu_target_item_handler P_ ((void));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
127 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
128 static OSStatus install_service_handler P_ ((void));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
129 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
130
cb749087dcc9 New file.
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,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
132 Lisp_Object,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
133 Lisp_Object,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
134 EventRef, UInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
135 const EventParamName *,
cb749087dcc9 New file.
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
144 #endif
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
145
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
146 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
147 extern OSStatus mac_restore_keyboard_input_source P_ ((void));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
148 extern void mac_save_keyboard_input_source P_ ((void));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
149
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
150 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
151 mac_tsm_resume ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
152 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
153 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
154
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
155 err = ActivateTSMDocument (tsm_document_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
156 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
157 err = mac_restore_keyboard_input_source ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
158
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
159 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
160 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
161
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
162 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
163 mac_tsm_suspend ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
164 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
165 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
166
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
167 mac_save_keyboard_input_source ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
168 err = DeactivateTSMDocument (tsm_document_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
169
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
170 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
171 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
172
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
173 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
174 init_tsm ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
175 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
176 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
177 static InterfaceTypeList types = {kUnicodeDocument};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
178 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
179 static InterfaceTypeList types = {kTextService};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
180 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
181
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
182 NewTSMDocument (sizeof (types) / sizeof (types[0]), types,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
183 &tsm_document_id, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
184 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
185 #endif /* USE_MAC_TSM */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
186
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
187 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
188 mac_handle_keyboard_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
189 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
190 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
191 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
192 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
193 OSStatus err, result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
194 UInt32 event_kind, key_code, modifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
195 unsigned char char_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
196
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
197 event_kind = GetEventKind (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
198 switch (event_kind)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
199 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
200 case kEventRawKeyDown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
201 case kEventRawKeyRepeat:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
202 case kEventRawKeyUp:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
203 /* When using Carbon Events, we need to pass raw keyboard events
cb749087dcc9 New file.
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
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
205 noErr, otherwise it will pass back "eventNotHandledErr" and
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
206 we can process it normally. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
207 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
208 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
209 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
210
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
211 if (read_socket_inev == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
212 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
213
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
214 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
215 if (read_socket_inev->kind != NO_EVENT)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
216 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
217 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
218 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
219 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
220 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
221
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
222 if (event_kind == kEventRawKeyUp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
223 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
224
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
225 err = GetEventParameter (event, kEventParamKeyMacCharCodes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
226 typeChar, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
227 sizeof (char), NULL, &char_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
228 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
229 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
230
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
231 err = GetEventParameter (event, kEventParamKeyCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
232 typeUInt32, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
233 sizeof (UInt32), NULL, &key_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
234 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
235 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
236
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
237 err = GetEventParameter (event, kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
238 typeUInt32, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
239 sizeof (UInt32), NULL, &modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
240 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
241 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
242
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
243 do_keystroke ((event_kind == kEventRawKeyDown ? keyDown : autoKey),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
244 char_code, key_code, modifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
245 ((unsigned long)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
246 (GetEventTime (event) / kEventDurationMillisecond)),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
247 read_socket_inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
248 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
249 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
250
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
251 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
252 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
253 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
254
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
255 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
256 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
257
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
258 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
259 mac_handle_command_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
260 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
261 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
262 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
263 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
264 OSStatus err, result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
265 HICommand command;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
266 static const EventParamName names[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
267 {kEventParamDirectObject, kEventParamKeyModifiers};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
268 static const EventParamType types[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
269 {typeHICommand, typeUInt32};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
270 int num_params = sizeof (names) / sizeof (names[0]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
271
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
272 err = GetEventParameter (event, kEventParamDirectObject, typeHICommand,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
273 NULL, sizeof (HICommand), NULL, &command);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
274 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
275 return eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
276
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
277 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
278 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
279 case kEventCommandProcess:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
280 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
281 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
282 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
283
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
284 err = GetEventParameter (event, kEventParamDirectObject,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
285 typeHICommand, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
286 sizeof (HICommand), NULL, &command);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
287
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
288 if (err != noErr || command.commandID == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
289 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
290
cb749087dcc9 New file.
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
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
292 class symbol is `hi-command' and event ID is its command
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
293 ID. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
294 err = mac_store_event_ref_as_apple_event (0, command.commandID,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
295 Qhi_command, Qnil,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
296 event, num_params,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
297 names, types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
298 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
299 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
300 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
301
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
302 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
303 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
304 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
305
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
306 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
307 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
308
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
309 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
310 mac_handle_mouse_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
311 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
312 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
313 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
314 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
315 OSStatus err, result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
316
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
317 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
318 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
319 case kEventMouseWheelMoved:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
320 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
321 WindowRef wp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
322 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
323 EventMouseWheelAxis axis;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
324 SInt32 delta;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
325 Point point;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
326
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
327 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
328 if (result != eventNotHandledErr || read_socket_inev == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
329 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
330
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
331 f = mac_focus_frame (&one_mac_display_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
332
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
333 err = GetEventParameter (event, kEventParamWindowRef, typeWindowRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
334 NULL, sizeof (WindowRef), NULL, &wp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
335 if (err != noErr
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
336 || wp != FRAME_MAC_WINDOW (f))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
337 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
338
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
339 err = GetEventParameter (event, kEventParamMouseWheelAxis,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
340 typeMouseWheelAxis, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
341 sizeof (EventMouseWheelAxis), NULL, &axis);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
342 if (err != noErr || axis != kEventMouseWheelAxisY)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
343 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
344
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
345 err = GetEventParameter (event, kEventParamMouseLocation,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
346 typeQDPoint, NULL, sizeof (Point),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
347 NULL, &point);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
348 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
349 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
350
cb749087dcc9 New file.
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);
cb749087dcc9 New file.
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);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
353 if (point.h < 0 || point.v < 0
cb749087dcc9 New file.
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),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
355 f->tool_bar_window))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
356 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
357
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
358 err = GetEventParameter (event, kEventParamMouseWheelDelta,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
359 typeSInt32, NULL, sizeof (SInt32),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
360 NULL, &delta);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
361 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
362 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
363
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
364 read_socket_inev->kind = WHEEL_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
365 read_socket_inev->code = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
366 read_socket_inev->modifiers =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
367 (mac_event_to_emacs_modifiers (event)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
368 | ((delta < 0) ? down_modifier : up_modifier));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
369 XSETINT (read_socket_inev->x, point.h);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
370 XSETINT (read_socket_inev->y, point.v);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
371 XSETFRAME (read_socket_inev->frame_or_window, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
372
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
373 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
374 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
375 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
376
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
377 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
378 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
379 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
380
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
381 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
382 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
383
cb749087dcc9 New file.
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
388
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
389 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
390 mac_handle_text_input_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
391 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
392 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
393 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
394 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
395 OSStatus err, result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
396 Lisp_Object id_key = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
397 int num_params;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
398 const EventParamName *names;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
399 const EventParamType *types;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
400 static UInt32 seqno_uaia = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
401 static const EventParamName names_uaia[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
402 {kEventParamTextInputSendComponentInstance,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
403 kEventParamTextInputSendRefCon,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
404 kEventParamTextInputSendSLRec,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
405 kEventParamTextInputSendFixLen,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
406 kEventParamTextInputSendText,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
407 kEventParamTextInputSendUpdateRng,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
408 kEventParamTextInputSendHiliteRng,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
409 kEventParamTextInputSendClauseRng,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
410 kEventParamTextInputSendPinRng,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
411 kEventParamTextInputSendTextServiceEncoding,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
412 kEventParamTextInputSendTextServiceMacEncoding,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
413 EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
414 static const EventParamType types_uaia[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
415 {typeComponentInstance,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
416 typeLongInteger,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
417 typeIntlWritingCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
418 typeLongInteger,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
419 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
420 typeUnicodeText,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
421 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
422 typeChar,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
423 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
424 typeTextRangeArray,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
425 typeTextRangeArray,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
426 typeOffsetArray,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
427 typeTextRange,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
428 typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
429 typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
430 typeUInt32};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
431 static const EventParamName names_ufke[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
432 {kEventParamTextInputSendComponentInstance,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
433 kEventParamTextInputSendRefCon,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
434 kEventParamTextInputSendSLRec,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
435 kEventParamTextInputSendText};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
436 static const EventParamType types_ufke[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
437 {typeComponentInstance,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
438 typeLongInteger,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
439 typeIntlWritingCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
440 typeUnicodeText};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
441
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
442 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
443 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
444 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
445
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
446 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
447 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
448 case kEventTextInputUpdateActiveInputArea:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
449 id_key = Qupdate_active_input_area;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
450 num_params = sizeof (names_uaia) / sizeof (names_uaia[0]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
451 names = names_uaia;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
452 types = types_uaia;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
453 SetEventParameter (event, EVENT_PARAM_TEXT_INPUT_SEQUENCE_NUMBER,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
454 typeUInt32, sizeof (UInt32), &seqno_uaia);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
455 seqno_uaia++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
456 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
457 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
458
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
459 case kEventTextInputUnicodeForKeyEvent:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
460 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
461 EventRef kbd_event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
462 UInt32 actual_size, modifiers, key_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
463
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
464 err = GetEventParameter (event, kEventParamTextInputSendKeyboardEvent,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
465 typeEventRef, NULL, sizeof (EventRef), NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
466 &kbd_event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
467 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
468 err = GetEventParameter (kbd_event, kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
469 typeUInt32, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
470 sizeof (UInt32), NULL, &modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
471 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
472 err = GetEventParameter (kbd_event, kEventParamKeyCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
473 typeUInt32, NULL, sizeof (UInt32),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
474 NULL, &key_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
475 if (err == noErr && mac_mapped_modifiers (modifiers, key_code))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
476 /* There're mapped modifier keys. Process it in
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
477 do_keystroke. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
478 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
479 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
480 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
481 typeUnicodeText, NULL, 0, &actual_size,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
482 NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
483 if (err == noErr && actual_size == sizeof (UniChar))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
484 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
485 UniChar code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
486
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
487 err = GetEventParameter (kbd_event, kEventParamKeyUnicodes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
488 typeUnicodeText, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
489 sizeof (UniChar), NULL, &code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
490 if (err == noErr && code < 0x80)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
491 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
492 /* ASCII character. Process it in do_keystroke. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
493 if (read_socket_inev && code >= 0x20 && code <= 0x7e
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
494 && !(key_code <= 0x7f
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
495 && keycode_to_xkeysym_table [key_code]))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
496 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
497 struct frame *f = mac_focus_frame (&one_mac_display_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
498
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
499 read_socket_inev->kind = ASCII_KEYSTROKE_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
500 read_socket_inev->code = code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
501 read_socket_inev->modifiers =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
502 mac_to_emacs_modifiers (modifiers, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
503 read_socket_inev->modifiers |=
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
504 (extra_keyboard_modifiers
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
505 & (meta_modifier | alt_modifier
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
506 | hyper_modifier | super_modifier));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
507 XSETFRAME (read_socket_inev->frame_or_window, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
508 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
509 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
510 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
511 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
512 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
513 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
514 /* Non-ASCII keystrokes without mapped modifiers are
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
515 processed at the Lisp level. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
516 id_key = Qunicode_for_key_event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
517 num_params = sizeof (names_ufke) / sizeof (names_ufke[0]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
518 names = names_ufke;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
519 types = types_ufke;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
520 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
521 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
522 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
523 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
524
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
525 case kEventTextInputOffsetToPos:
cb749087dcc9 New file.
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>
parents: 80517
diff changeset
527 long byte_offset;
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
528 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
529 struct window *w;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
530 Point p;
cb749087dcc9 New file.
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
535 if (err != noErr)
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
536 break;
cb749087dcc9 New file.
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>
parents: 80517
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>
parents: 80517
diff changeset
539 && SBYTES (Vmac_ts_active_input_buf) != 0)
80446
cb749087dcc9 New file.
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>
parents: 80517
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>
parents: 80517
diff changeset
542 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
543
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
547 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
551 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
diff changeset
553 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
557 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
558 else
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
559 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
560
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
566 + f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f));
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
567 }
cb749087dcc9 New file.
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>
parents: 80517
diff changeset
569 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
diff changeset
571 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
577 struct glyph *glyph;
80606
557c72d63824 [USE_MAC_TSM] (mac_handle_text_input_event):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80520
diff changeset
578 struct face *face;
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
579
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
585
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
diff changeset
587 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
diff changeset
589 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
590 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
591
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
595 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
596
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
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>
parents: 80517
diff changeset
602
80606
557c72d63824 [USE_MAC_TSM] (mac_handle_text_input_event):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80520
diff changeset
603 face = FACE_FROM_ID (f, glyph->face_id);
557c72d63824 [USE_MAC_TSM] (mac_handle_text_input_event):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80520
diff changeset
604 if (face && face->font)
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
605 {
80606
557c72d63824 [USE_MAC_TSM] (mac_handle_text_input_event):
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80520
diff changeset
606 XFontStruct *font = face->font;
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
607 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>
parents: 80517
diff changeset
608 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>
parents: 80517
diff changeset
609 short ascent = row->ascent;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
610
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
611 SetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
612 kEventParamTextInputReplyPointSize,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
613 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>
parents: 80517
diff changeset
614 SetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
615 kEventParamTextInputReplyLineHeight,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
616 typeShortInteger, sizeof (short), &height);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
617 SetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
618 kEventParamTextInputReplyLineAscent,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
619 typeShortInteger, sizeof (short), &ascent);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
620 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>
parents: 80517
diff changeset
621 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
622 OSStatus err1;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
623 FMFont fm_font;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
624 FMFontStyle style;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
625
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
626 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>
parents: 80517
diff changeset
627 font->mac_fontface,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
628 &fm_font, &style);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
629 if (err1 == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
630 SetEventParameter (event, kEventParamTextInputReplyFMFont,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
631 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>
parents: 80517
diff changeset
632 else
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
633 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
634 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>
parents: 80517
diff changeset
635
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
636 SetEventParameter (event, kEventParamTextInputReplyFont,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
637 typeLongInteger, sizeof (long),
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
638 &qd_font);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
639 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
640 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
641 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>
parents: 80517
diff changeset
642 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
643 OSStatus err1;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
644 ATSUFontID font_id;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
645
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
646 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>
parents: 80517
diff changeset
647 sizeof (ATSUFontID), &font_id,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
648 NULL);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
649 if (err1 == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
650 SetEventParameter (event, kEventParamTextInputReplyFMFont,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
651 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>
parents: 80517
diff changeset
652 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
653 else
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
654 abort ();
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
655 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
656 #endif /* MAC_OSX */
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
657 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
658
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
659 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>
parents: 80517
diff changeset
660 typeQDPoint, sizeof (Point), &p);
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
661 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
662 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
663 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
664 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
665
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
666 #ifdef MAC_OSX
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
667 case kEventTextInputPosToOffset:
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
668 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
669 Point point;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
670 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>
parents: 80517
diff changeset
671 struct frame *f;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
672 int x, y;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
673 Lisp_Object window;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
674 enum window_part part;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
675 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>
parents: 80517
diff changeset
676
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
677 err = GetEventParameter (event, kEventParamTextInputSendCurrentPoint,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
678 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>
parents: 80517
diff changeset
679 &point);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
680 if (err != noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
681 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
682
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
683 GetEventParameter (event, kEventParamTextInputReplyLeadingEdge,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
684 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>
parents: 80517
diff changeset
685 &leading_edge_p);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
686
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
687 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>
parents: 80517
diff changeset
688 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>
parents: 80517
diff changeset
689 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>
parents: 80517
diff changeset
690 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>
parents: 80517
diff changeset
691 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>
parents: 80517
diff changeset
692 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
693 struct window *w;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
694 struct buffer *b;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
695
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
696 /* 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>
parents: 80517
diff changeset
697 w = XWINDOW (window);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
698 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>
parents: 80517
diff changeset
699
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
700 /* 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>
parents: 80517
diff changeset
701 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>
parents: 80517
diff changeset
702 b = XBUFFER (w->buffer);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
703 if (part == ON_TEXT
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
704 && 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>
parents: 80517
diff changeset
705 && 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>
parents: 80517
diff changeset
706 && 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>
parents: 80517
diff changeset
707 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
708 int hpos, vpos, area;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
709 struct glyph *glyph;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
710
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
711 /* 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>
parents: 80517
diff changeset
712 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>
parents: 80517
diff changeset
713
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
714 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>
parents: 80517
diff changeset
715 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
716 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>
parents: 80517
diff changeset
717 * sizeof (UniChar));
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
718 region_class = kTSMInsideOfBody;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
719 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
720 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
721 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
722
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
723 err = SetEventParameter (event, kEventParamTextInputReplyRegionClass,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
724 typeLongInteger, sizeof (long),
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
725 &region_class);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
726 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
727 err = SetEventParameter (event, kEventParamTextInputReplyTextOffset,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
728 typeLongInteger, sizeof (long),
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
729 &byte_offset);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
730 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
731 result = noErr;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
732 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
733 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
734
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
735 case kEventTextInputGetSelectedText:
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
736 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
737 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>
parents: 80517
diff changeset
738 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>
parents: 80517
diff changeset
739 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>
parents: 80517
diff changeset
740 CFRange sel_range;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
741 int start, end;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
742 UniChar *characters, c;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
743
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
744 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>
parents: 80517
diff changeset
745 /* 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>
parents: 80517
diff changeset
746 being altered. */
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
747 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
748
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
749 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>
parents: 80517
diff changeset
750 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>
parents: 80517
diff changeset
751 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
752 Boolean leading_edge_p;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
753
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
754 err = GetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
755 kEventParamTextInputReplyLeadingEdge,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
756 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>
parents: 80517
diff changeset
757 &leading_edge_p);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
758 if (err != noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
759 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
760
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
761 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>
parents: 80517
diff changeset
762 if (!leading_edge_p)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
763 start--;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
764 end = start + 1;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
765 characters = &c;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
766
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
767 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>
parents: 80517
diff changeset
768 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
769 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
770 else
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
771 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
772 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>
parents: 80517
diff changeset
773 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>
parents: 80517
diff changeset
774 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>
parents: 80517
diff changeset
775 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
776
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
777 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>
parents: 80517
diff changeset
778 err = SetEventParameter (event, kEventParamTextInputReplyText,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
779 typeUnicodeText,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
780 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>
parents: 80517
diff changeset
781 characters);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
782 if (characters != &c)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
783 xfree (characters);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
784
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
785 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
786 result = noErr;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
787 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
788 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
789 #endif /* MAC_OSX */
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
790
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
791 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
792 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
793 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
794
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
795 if (!NILP (id_key))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
796 err = mac_store_event_ref_as_apple_event (0, 0, Qtext_input, id_key,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
797 event, num_params,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
798 names, types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
799 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
800 }
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
801
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
802 #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>
parents: 80517
diff changeset
803 static pascal OSStatus
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
804 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>
parents: 80517
diff changeset
805 EventHandlerCallRef next_handler;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
806 EventRef event;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
807 void *data;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
808 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
809 OSStatus err, result;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
810 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>
parents: 80517
diff changeset
811
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
812 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>
parents: 80517
diff changeset
813 if (result != eventNotHandledErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
814 return result;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
815
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
816 switch (GetEventKind (event))
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
817 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
818 case kEventTSMDocumentAccessGetLength:
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
819 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
820 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>
parents: 80517
diff changeset
821
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
822 err = SetEventParameter (event, kEventParamTSMDocAccessCharacterCount,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
823 typeCFIndex, sizeof (CFIndex), &count);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
824 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
825 result = noErr;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
826 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
827 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
828
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
829 case kEventTSMDocumentAccessGetSelectedRange:
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
830 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
831 CFRange sel_range;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
832
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
833 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>
parents: 80517
diff changeset
834 err = SetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
835 kEventParamTSMDocAccessReplyCharacterRange,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
836 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>
parents: 80517
diff changeset
837 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
838 result = noErr;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
839 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
840 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
841
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
842 case kEventTSMDocumentAccessGetCharacters:
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
843 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
844 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>
parents: 80517
diff changeset
845 CFRange range;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
846 Ptr characters;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
847 int start, end;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
848
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
849 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>
parents: 80517
diff changeset
850 /* 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>
parents: 80517
diff changeset
851 being altered. */
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
852 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
853
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
854 err = GetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
855 kEventParamTSMDocAccessSendCharacterRange,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
856 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>
parents: 80517
diff changeset
857 &range);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
858 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
859 err = GetEventParameter (event,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
860 kEventParamTSMDocAccessSendCharactersPtr,
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
861 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>
parents: 80517
diff changeset
862 &characters);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
863 if (err != noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
864 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
865
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
866 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>
parents: 80517
diff changeset
867 end = start + range.length;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
868 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>
parents: 80517
diff changeset
869 (UniChar *) characters))
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
870 result = noErr;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
871 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
872 break;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
873
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
874 default:
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
875 abort ();
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
876 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
877
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
878 return result;
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
879 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
880 #endif
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
881 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
882
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
883 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
884 install_application_handler ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
885 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
886 OSStatus err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
887
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
888 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
889 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
890 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
891 {{kEventClassKeyboard, kEventRawKeyDown},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
892 {kEventClassKeyboard, kEventRawKeyRepeat},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
893 {kEventClassKeyboard, kEventRawKeyUp}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
894
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
895 err = InstallApplicationEventHandler (NewEventHandlerUPP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
896 (mac_handle_keyboard_event),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
897 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
898 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
899 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
900
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
901 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
902 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
903 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
904 {{kEventClassCommand, kEventCommandProcess}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
905
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
906 err = InstallApplicationEventHandler (NewEventHandlerUPP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
907 (mac_handle_command_event),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
908 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
909 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
910 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
911
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
912 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
913 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
914 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
915 {{kEventClassMouse, kEventMouseWheelMoved}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
916
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
917 err = InstallApplicationEventHandler (NewEventHandlerUPP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
918 (mac_handle_mouse_event),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
919 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
920 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
921 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
922
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
923 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
924 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
925 {
80517
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
926 static const EventTypeSpec specs[] =
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
927 {{kEventClassTextInput, kEventTextInputUpdateActiveInputArea},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
928 {kEventClassTextInput, kEventTextInputUnicodeForKeyEvent},
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
929 {kEventClassTextInput, kEventTextInputOffsetToPos},
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
930 #ifdef MAC_OSX
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
931 {kEventClassTextInput, kEventTextInputPosToOffset},
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
932 {kEventClassTextInput, kEventTextInputGetSelectedText}
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
933 #endif
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
934 };
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
935
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
936 err = InstallApplicationEventHandler (NewEventHandlerUPP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
937 (mac_handle_text_input_event),
80517
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
938 GetEventTypeCount (specs),
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
939 specs, NULL, NULL);
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
940 }
80520
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
941
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
942 #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>
parents: 80517
diff changeset
943 if (err == noErr)
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
944 {
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
945 static const EventTypeSpec specs[] =
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
946 {{kEventClassTSMDocumentAccess, kEventTSMDocumentAccessGetLength},
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
947 {kEventClassTSMDocumentAccess, kEventTSMDocumentAccessGetSelectedRange},
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
948 {kEventClassTSMDocumentAccess, kEventTSMDocumentAccessGetCharacters}};
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
949
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
950 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>
parents: 80517
diff changeset
951 GetEventTypeCount (specs),
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
952 specs, NULL, NULL);
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
953 }
aaff809b3a06 (Vmac_ts_active_input_buf) [USE_MAC_TSM]: Add extern.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80517
diff changeset
954 #endif
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
955 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
956
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
957 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
958 err = install_menu_target_item_handler ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
959
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
960 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
961 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
962 err = install_service_handler ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
963 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
964
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
965 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
966 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
967 #endif /* TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
968
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
969
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
970 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
971 Windows
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
972 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
973
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
974 #define DEFAULT_NUM_COLS 80
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
975
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
976 #define MIN_DOC_SIZE 64
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
977 #define MAX_DOC_SIZE 32767
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
978
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
979 /* Drag and Drop */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
980 static OSErr install_drag_handler P_ ((WindowRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
981 static void remove_drag_handler P_ ((WindowRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
982
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
983 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
984 static void mac_prepare_for_quickdraw P_ ((struct frame *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
985 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
986
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
987 extern void mac_handle_visibility_change P_ ((struct frame *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
988 extern void mac_handle_origin_change P_ ((struct frame *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
989 extern void mac_handle_size_change P_ ((struct frame *, int, int));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
990
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
991 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
992 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
993 extern Lisp_Object Qwindow;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
994 extern Lisp_Object Qtoolbar_switch_mode;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
995 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
996 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
997
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
998 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
999 do_window_update (WindowRef win)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1000 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1001 struct frame *f = mac_window_to_frame (win);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1002
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1003 BeginUpdate (win);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1004
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1005 /* The tooltip has been drawn already. Avoid the SET_FRAME_GARBAGED
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1006 below. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1007 if (win != tip_window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1008 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1009 if (f->async_visible == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1010 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1011 /* Update events may occur when a frame gets iconified. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1012 #if 0
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1013 f->async_visible = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1014 f->async_iconified = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1015 SET_FRAME_GARBAGED (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1016 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1017 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1018 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1019 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1020 Rect r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1021 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1022 RgnHandle region = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1023
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1024 GetPortVisibleRegion (GetWindowPort (win), region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1025 GetRegionBounds (region, &r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1026 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1027 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1028 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1029 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1030 UpdateControls (win, region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1031 DisposeRgn (region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1032 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1033 r = (*win->visRgn)->rgnBBox;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1034 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1035 UpdateControls (win, win->visRgn);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1036 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1037 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1038 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1039
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1040 EndUpdate (win);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1041 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1042
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1043 static int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1044 is_emacs_window (WindowRef win)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1045 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1046 Lisp_Object tail, frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1047
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1048 if (!win)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1049 return 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1050
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1051 FOR_EACH_FRAME (tail, frame)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1052 if (FRAME_MAC_P (XFRAME (frame)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1053 if (FRAME_MAC_WINDOW (XFRAME (frame)) == win)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1054 return 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1055
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1056 return 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1057 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1058
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1059 /* Handle drags in size box. Based on code contributed by Ben
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1060 Mesander and IM - Window Manager A. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1061
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1062 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1063 do_grow_window (w, e)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1064 WindowRef w;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1065 const EventRecord *e;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1066 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1067 Rect limit_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1068 int rows, columns, width, height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1069 struct frame *f = mac_window_to_frame (w);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1070 XSizeHints *size_hints = FRAME_SIZE_HINTS (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1071 int min_width = MIN_DOC_SIZE, min_height = MIN_DOC_SIZE;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1072 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1073 Rect new_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1074 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1075 long grow_size;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1076 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1077
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1078 if (size_hints->flags & PMinSize)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1079 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1080 min_width = size_hints->min_width;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1081 min_height = size_hints->min_height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1082 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1083 SetRect (&limit_rect, min_width, min_height, MAX_DOC_SIZE, MAX_DOC_SIZE);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1084
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1085 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1086 if (!ResizeWindow (w, e->where, &limit_rect, &new_rect))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1087 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1088 height = new_rect.bottom - new_rect.top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1089 width = new_rect.right - new_rect.left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1090 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1091 grow_size = GrowWindow (w, e->where, &limit_rect);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1092 /* see if it really changed size */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1093 if (grow_size == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1094 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1095 height = HiWord (grow_size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1096 width = LoWord (grow_size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1097 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1098
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1099 if (width != FRAME_PIXEL_WIDTH (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1100 || height != FRAME_PIXEL_HEIGHT (f))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1101 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1102 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1103 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1104
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1105 x_set_window_size (f, 0, columns, rows);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1106 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1107 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1108
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1109 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1110 static Point
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1111 mac_get_ideal_size (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1112 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1113 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1114 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1115 WindowRef w = FRAME_MAC_WINDOW (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1116 Point ideal_size;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1117 Rect standard_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1118 int height, width, columns, rows;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1119
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1120 ideal_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1121 ideal_size.v = dpyinfo->height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1122 IsWindowInStandardState (w, &ideal_size, &standard_rect);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1123 /* Adjust the standard size according to character boundaries. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1124 width = standard_rect.right - standard_rect.left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1125 height = standard_rect.bottom - standard_rect.top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1126 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1127 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1128 ideal_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, columns);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1129 ideal_size.v = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1130
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1131 return ideal_size;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1132 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1133
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1134 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1135 mac_handle_window_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1136 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1137 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1138 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1139 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1140 WindowRef wp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1141 OSStatus err, result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1142 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1143 UInt32 attributes;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1144 XSizeHints *size_hints;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1145
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1146 err = GetEventParameter (event, kEventParamDirectObject, typeWindowRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1147 NULL, sizeof (WindowRef), NULL, &wp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1148 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1149 return eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1150
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1151 f = mac_window_to_frame (wp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1152 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1153 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1154 /* -- window refresh events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1155
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1156 case kEventWindowUpdate:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1157 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1158 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1159 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1160
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1161 do_window_update (wp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1162 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1163 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1164
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1165 /* -- window state change events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1166
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1167 case kEventWindowShowing:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1168 size_hints = FRAME_SIZE_HINTS (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1169 if (!(size_hints->flags & (USPosition | PPosition)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1170 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1171 struct frame *sf = SELECTED_FRAME ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1172
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1173 if (!(FRAME_MAC_P (sf) && sf->async_visible))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1174 RepositionWindow (wp, NULL, kWindowCenterOnMainScreen);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1175 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1176 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1177 RepositionWindow (wp, FRAME_MAC_WINDOW (sf),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1178 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1179 kWindowCascadeStartAtParentWindowScreen
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1180 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1181 kWindowCascadeOnParentWindowScreen
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1182 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1183 );
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1184 #if USE_MAC_TOOLBAR
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1185 /* This is a workaround. RepositionWindow fails to put
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1186 a window at the cascading position when its parent
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1187 window has a Carbon HIToolbar. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1188 if ((f->left_pos == sf->left_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1189 && f->top_pos == sf->top_pos)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1190 || (f->left_pos == sf->left_pos + 10 * 2
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1191 && f->top_pos == sf->top_pos + 32 * 2))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1192 MoveWindowStructure (wp, sf->left_pos + 10, sf->top_pos + 32);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1193 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1194 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1195 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1196 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1197 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1198
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1199 case kEventWindowHiding:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1200 /* Before unmapping the window, update the WM_SIZE_HINTS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1201 property to claim that the current position of the window is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1202 user-specified, rather than program-specified, so that when
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1203 the window is mapped again, it will be placed at the same
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1204 location, without forcing the user to position it by hand
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1205 again (they have already done that once for this window.) */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1206 x_wm_set_size_hint (f, (long) 0, 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1207 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1208 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1209
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1210 case kEventWindowShown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1211 case kEventWindowHidden:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1212 case kEventWindowCollapsed:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1213 case kEventWindowExpanded:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1214 mac_handle_visibility_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1215 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1216 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1217
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1218 case kEventWindowBoundsChanging:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1219 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1220 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1221 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1222
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1223 err = GetEventParameter (event, kEventParamAttributes, typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1224 NULL, sizeof (UInt32), NULL, &attributes);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1225 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1226 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1227
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1228 size_hints = FRAME_SIZE_HINTS (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1229 if ((attributes & kWindowBoundsChangeUserResize)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1230 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1231 == (PResizeInc | PBaseSize | PMinSize)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1232 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1233 Rect bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1234 int width, height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1235
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1236 err = GetEventParameter (event, kEventParamCurrentBounds,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1237 typeQDRectangle, NULL, sizeof (Rect),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1238 NULL, &bounds);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1239 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1240 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1241
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1242 width = bounds.right - bounds.left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1243 height = bounds.bottom - bounds.top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1244
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1245 if (width < size_hints->min_width)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1246 width = size_hints->min_width;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1247 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1248 width = size_hints->base_width
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1249 + (int) ((width - size_hints->base_width)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1250 / (float) size_hints->width_inc + .5)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1251 * size_hints->width_inc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1252
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1253 if (height < size_hints->min_height)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1254 height = size_hints->min_height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1255 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1256 height = size_hints->base_height
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1257 + (int) ((height - size_hints->base_height)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1258 / (float) size_hints->height_inc + .5)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1259 * size_hints->height_inc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1260
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1261 bounds.right = bounds.left + width;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1262 bounds.bottom = bounds.top + height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1263 SetEventParameter (event, kEventParamCurrentBounds,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1264 typeQDRectangle, sizeof (Rect), &bounds);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1265 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1266 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1267 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1268
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1269 case kEventWindowBoundsChanged:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1270 err = GetEventParameter (event, kEventParamAttributes, typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1271 NULL, sizeof (UInt32), NULL, &attributes);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1272 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1273 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1274
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1275 if (attributes & kWindowBoundsChangeSizeChanged)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1276 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1277 Rect bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1278
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1279 err = GetEventParameter (event, kEventParamCurrentBounds,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1280 typeQDRectangle, NULL, sizeof (Rect),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1281 NULL, &bounds);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1282 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1283 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1284 int width, height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1285
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1286 width = bounds.right - bounds.left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1287 height = bounds.bottom - bounds.top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1288 mac_handle_size_change (f, width, height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1289 mac_wakeup_from_rne ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1290 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1291 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1292
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1293 if (attributes & kWindowBoundsChangeOriginChanged)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1294 mac_handle_origin_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1295
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1296 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1297 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1298
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1299 /* -- window action events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1300
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1301 case kEventWindowClose:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1302 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1303 struct input_event buf;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1304
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1305 EVENT_INIT (buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1306 buf.kind = DELETE_WINDOW_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1307 XSETFRAME (buf.frame_or_window, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1308 buf.arg = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1309 kbd_buffer_store_event (&buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1310 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1311 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1312 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1313
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1314 case kEventWindowGetIdealSize:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1315 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1316 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1317 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1318
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1319 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1320 Point ideal_size = mac_get_ideal_size (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1321
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1322 err = SetEventParameter (event, kEventParamDimensions,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1323 typeQDPoint, sizeof (Point), &ideal_size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1324 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1325 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1326 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1327 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1328
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1329 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1330 case kEventWindowToolbarSwitchMode:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1331 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1332 static const EventParamName names[] = {kEventParamDirectObject,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1333 kEventParamWindowMouseLocation,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1334 kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1335 kEventParamMouseButton,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1336 kEventParamClickCount,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1337 kEventParamMouseChord};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1338 static const EventParamType types[] = {typeWindowRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1339 typeQDPoint,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1340 typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1341 typeMouseButton,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1342 typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1343 typeUInt32};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1344 int num_params = sizeof (names) / sizeof (names[0]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1345
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1346 err = mac_store_event_ref_as_apple_event (0, 0,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1347 Qwindow,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1348 Qtoolbar_switch_mode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1349 event, num_params,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1350 names, types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1351 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1352 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1353 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1354 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1355 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1356
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1357 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1358 /* -- window focus events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1359
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1360 case kEventWindowFocusAcquired:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1361 err = mac_tsm_resume ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1362 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1363 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1364 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1365
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1366 case kEventWindowFocusRelinquish:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1367 err = mac_tsm_suspend ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1368 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1369 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1370 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1371 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1372
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1373 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1374 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1375 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1376
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1377 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1378 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1379 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1380
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1381 /* Handle clicks in zoom box. Calculation of "standard state" based
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1382 on code in IM - Window Manager A and code contributed by Ben
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1383 Mesander. The standard state of an Emacs window is 80-characters
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1384 wide (DEFAULT_NUM_COLS) and as tall as will fit on the screen. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1385
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1386 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1387 do_zoom_window (WindowRef w, int zoom_in_or_out)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1388 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1389 Rect zoom_rect, port_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1390 int width, height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1391 struct frame *f = mac_window_to_frame (w);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1392 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1393 Point ideal_size = mac_get_ideal_size (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1394
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1395 GetWindowBounds (w, kWindowContentRgn, &port_rect);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1396 if (IsWindowInStandardState (w, &ideal_size, &zoom_rect)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1397 && port_rect.left == zoom_rect.left
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1398 && port_rect.top == zoom_rect.top)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1399 zoom_in_or_out = inZoomIn;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1400 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1401 zoom_in_or_out = inZoomOut;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1402
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1403 #ifdef MAC_OS8
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1404 mac_clear_area (f, 0, 0, port_rect.right - port_rect.left,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1405 port_rect.bottom - port_rect.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1406 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1407 ZoomWindowIdeal (w, zoom_in_or_out, &ideal_size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1408 #else /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1409 GrafPtr save_port;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1410 Point top_left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1411 int w_title_height, rows;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1412 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1413
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1414 GetPort (&save_port);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1415
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1416 SetPortWindowPort (w);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1417
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1418 /* Clear window to avoid flicker. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1419 EraseRect (&(w->portRect));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1420 if (zoom_in_or_out == inZoomOut)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1421 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1422 SetPt (&top_left, w->portRect.left, w->portRect.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1423 LocalToGlobal (&top_left);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1424
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1425 /* calculate height of window's title bar */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1426 w_title_height = top_left.v - 1
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1427 - (**((WindowPeek) w)->strucRgn).rgnBBox.top + GetMBarHeight ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1428
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1429 /* get maximum height of window into zoom_rect.bottom - zoom_rect.top */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1430 zoom_rect = qd.screenBits.bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1431 zoom_rect.top += w_title_height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1432 InsetRect (&zoom_rect, 8, 4); /* not too tight */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1433
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1434 zoom_rect.right = zoom_rect.left
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1435 + FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1436
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1437 /* Adjust the standard size according to character boundaries. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1438 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, zoom_rect.bottom - zoom_rect.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1439 zoom_rect.bottom =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1440 zoom_rect.top + FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, rows);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1441
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1442 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1443 = zoom_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1444 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1445
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1446 ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1447
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1448 SetPort (save_port);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1449 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1450
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1451 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1452 /* retrieve window size and update application values */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1453 port_rect = w->portRect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1454 height = port_rect.bottom - port_rect.top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1455 width = port_rect.right - port_rect.left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1456
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1457 mac_handle_size_change (f, width, height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1458 mac_handle_origin_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1459 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1460 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1461
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1462 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1463 install_window_handler (window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1464 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1465 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1466 OSStatus err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1467
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1468 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1469 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1470 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1471 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1472 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1473 /* -- window refresh events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1474 {kEventClassWindow, kEventWindowUpdate},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1475 /* -- window state change events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1476 {kEventClassWindow, kEventWindowShowing},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1477 {kEventClassWindow, kEventWindowHiding},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1478 {kEventClassWindow, kEventWindowShown},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1479 {kEventClassWindow, kEventWindowHidden},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1480 {kEventClassWindow, kEventWindowCollapsed},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1481 {kEventClassWindow, kEventWindowExpanded},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1482 {kEventClassWindow, kEventWindowBoundsChanging},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1483 {kEventClassWindow, kEventWindowBoundsChanged},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1484 /* -- window action events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1485 {kEventClassWindow, kEventWindowClose},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1486 {kEventClassWindow, kEventWindowGetIdealSize},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1487 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1488 {kEventClassWindow, kEventWindowToolbarSwitchMode},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1489 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1490 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1491 /* -- window focus events -- */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1492 {kEventClassWindow, kEventWindowFocusAcquired},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1493 {kEventClassWindow, kEventWindowFocusRelinquish},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1494 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1495 };
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1496 static EventHandlerUPP handle_window_eventUPP = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1497
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1498 if (handle_window_eventUPP == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1499 handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1500
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1501 err = InstallWindowEventHandler (window, handle_window_eventUPP,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1502 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1503 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1504 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1505 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1506
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1507 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1508 err = install_drag_handler (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1509
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1510 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1511 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1512
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1513 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1514 remove_window_handler (window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1515 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1516 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1517 remove_drag_handler (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1518 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1519
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1520 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1521 mac_get_window_bounds (f, inner, outer)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1522 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1523 Rect *inner, *outer;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1524 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1525 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1526 GetWindowBounds (FRAME_MAC_WINDOW (f), kWindowContentRgn, inner);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1527 GetWindowBounds (FRAME_MAC_WINDOW (f), kWindowStructureRgn, outer);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1528 #else /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1529 RgnHandle region = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1530
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1531 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowContentRgn, region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1532 *inner = (*region)->rgnBBox;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1533 GetWindowRegion (FRAME_MAC_WINDOW (f), kWindowStructureRgn, region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1534 *outer = (*region)->rgnBBox;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1535 DisposeRgn (region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1536 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1537 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1538
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1539 Rect *
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1540 mac_get_frame_bounds (f, r)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1541 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1542 Rect *r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1543 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1544 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1545 return GetWindowPortBounds (FRAME_MAC_WINDOW (f), r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1546 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1547 *r = FRAME_MAC_WINDOW (f)->portRect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1548
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1549 return r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1550 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1551 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1552
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1553 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1554 mac_get_frame_mouse (f, point)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1555 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1556 Point *point;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1557 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1558 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1559 GetGlobalMouse (point);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1560 point->h -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1561 point->v -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1562 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1563 SetPortWindowPort (FRAME_MAC_WINDOW (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1564 GetMouse (point);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1565 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1566 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1567
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1568 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1569 mac_convert_frame_point_to_global (f, x, y)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1570 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1571 int *x, *y;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1572 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1573 *x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1574 *y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1575 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1576
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1577 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1578 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1579 mac_update_proxy_icon (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1580 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1581 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1582 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1583 Lisp_Object file_name =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1584 XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1585 Window w = FRAME_MAC_WINDOW (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1586 AliasHandle alias = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1587
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1588 err = GetWindowProxyAlias (w, &alias);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1589 if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1590 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1591
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1592 if (STRINGP (file_name))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1593 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1594 AEDesc desc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1595 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1596 FSRef fref, fref_proxy;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1597 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1598 FSSpec fss, fss_proxy;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1599 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1600 Boolean changed;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1601 Lisp_Object encoded_file_name = ENCODE_FILE (file_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1602
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1603 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1604 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1605 SBYTES (encoded_file_name), typeFSRef, &desc);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1606 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1607 SetPortWindowPort (w);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1608 err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1609 SBYTES (encoded_file_name), typeFSS, &desc);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1610 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1611 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1612 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1613 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1614 err = AEGetDescData (&desc, &fref, sizeof (FSRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1615 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1616 err = AEGetDescData (&desc, &fss, sizeof (FSSpec));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1617 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1618 AEDisposeDesc (&desc);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1619 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1620 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1621 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1622 if (alias)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1623 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1624 /* (FS)ResolveAlias never sets `changed' to true if
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1625 `alias' is minimal. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1626 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1627 err = FSResolveAlias (NULL, alias, &fref_proxy, &changed);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1628 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1629 err = FSCompareFSRefs (&fref, &fref_proxy);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1630 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1631 err = ResolveAlias (NULL, alias, &fss_proxy, &changed);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1632 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1633 err = !(fss.vRefNum == fss_proxy.vRefNum
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1634 && fss.parID == fss_proxy.parID
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1635 && EqualString (fss.name, fss_proxy.name,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1636 false, true));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1637 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1638 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1639 if (err != noErr || alias == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1640 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1641 if (alias)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1642 DisposeHandle ((Handle) alias);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1643 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1644 err = FSNewAliasMinimal (&fref, &alias);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1645 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1646 err = NewAliasMinimal (&fss, &alias);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1647 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1648 changed = true;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1649 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1650 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1651 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1652 if (changed)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1653 err = SetWindowProxyAlias (w, alias);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1654 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1655
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1656 if (alias)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1657 DisposeHandle ((Handle) alias);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1658
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1659 if (err != noErr || !STRINGP (file_name))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1660 RemoveWindowProxy (w);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1661 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1662 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1663
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1664 /* Mac replacement for XSetWindowBackground. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1665
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1666 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1667 mac_set_frame_window_background (f, color)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1668 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1669 unsigned long color;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1670 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1671 WindowRef w = FRAME_MAC_WINDOW (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1672 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1673 AuxWinHandle aw_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1674 CTabHandle ctab_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1675 ColorSpecPtr ct_table;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1676 short ct_size;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1677 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1678 RGBColor bg_color;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1679
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1680 bg_color.red = RED16_FROM_ULONG (color);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1681 bg_color.green = GREEN16_FROM_ULONG (color);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1682 bg_color.blue = BLUE16_FROM_ULONG (color);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1683
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1684 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1685 SetWindowContentColor (w, &bg_color);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1686 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1687 if (GetAuxWin (w, &aw_handle))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1688 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1689 ctab_handle = (*aw_handle)->awCTable;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1690 HandToHand ((Handle *) &ctab_handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1691 ct_table = (*ctab_handle)->ctTable;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1692 ct_size = (*ctab_handle)->ctSize;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1693 while (ct_size > -1)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1694 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1695 if (ct_table->value == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1696 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1697 ct_table->rgb = bg_color;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1698 CTabChanged (ctab_handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1699 SetWinColor (w, (WCTabHandle) ctab_handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1700 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1701 ct_size--;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1702 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1703 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1704 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1705 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1706
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1707 /* Flush display of frame F, or of all frames if F is null. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1708
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1709 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1710 x_flush (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1711 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1712 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1713 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1714 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1715 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1716 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1717 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1718 if (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1719 QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1720 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1721 QDFlushPortBuffer (GetQDGlobalsThePort (), NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1722 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1723 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1724 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1725
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1726 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1727 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1728 mac_flush_display_optional (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1729 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1730 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1731 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1732 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1733 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1734 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1735 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1736
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1737 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1738 mac_update_begin (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1739 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1740 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1741 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1742 /* During update of a frame, availability of input events is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1743 periodically checked with ReceiveNextEvent if
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1744 redisplay-dont-pause is nil. That normally flushes window buffer
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1745 changes for every check, and thus screen update looks waving even
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1746 if no input is available. So we disable screen updates during
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1747 update of a frame. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1748 DisableScreenUpdates ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1749 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1750 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1751
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1752 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1753 mac_update_end (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1754 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1755 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1756 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1757 EnableScreenUpdates ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1758 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1759 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1760
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1761 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1762 mac_frame_up_to_date (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1763 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1764 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1765 /* Nothing to do. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1766 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1767
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1768 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1769 mac_create_frame_window (f, tooltip_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1770 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1771 int tooltip_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1772 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1773 Rect r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1774 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1775 WindowClass window_class;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1776 WindowAttributes attributes;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1777 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1778 short proc_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1779 WindowRef behind;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1780 Boolean go_away_flag;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1781 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1782
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1783 if (!tooltip_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1784 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1785 SetRect (&r, f->left_pos, f->top_pos,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1786 f->left_pos + FRAME_PIXEL_WIDTH (f),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1787 f->top_pos + FRAME_PIXEL_HEIGHT (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1788 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1789 window_class = kDocumentWindowClass;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1790 attributes = (kWindowStandardDocumentAttributes
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1791 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1792 | kWindowToolbarButtonAttribute
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1793 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1794 );
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1795 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1796 proc_id = zoomDocProc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1797 behind = (WindowRef) -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1798 go_away_flag = true;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1799 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1800 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1801 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1802 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1803 SetRect (&r, 0, 0, 1, 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1804 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1805 window_class = kHelpWindowClass;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1806 attributes = (kWindowNoUpdatesAttribute
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1807 | kWindowNoActivatesAttribute
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1808 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1809 | kWindowIgnoreClicksAttribute
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1810 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1811 );
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1812 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1813 proc_id = plainDBox;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1814 behind = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1815 go_away_flag = false;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1816 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1817 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1818
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1819 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1820 CreateNewWindow (window_class, attributes, &r, &FRAME_MAC_WINDOW (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1821 if (FRAME_MAC_WINDOW (f))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1822 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1823 SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1824 if (!tooltip_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1825 if (install_window_handler (FRAME_MAC_WINDOW (f)) != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1826 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1827 DisposeWindow (FRAME_MAC_WINDOW (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1828 FRAME_MAC_WINDOW (f) = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1829 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1830 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1831 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1832 FRAME_MAC_WINDOW (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1833 = NewCWindow (NULL, &r, "\p", false, proc_id, behind, go_away_flag,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1834 (long) f->output_data.mac);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1835 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1836 /* so that update events can find this mac_output struct */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1837 f->output_data.mac->mFP = f; /* point back to emacs frame */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1838
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1839 #ifndef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1840 if (!tooltip_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1841 if (FRAME_MAC_WINDOW (f))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1842 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1843 ControlRef root_control;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1844
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1845 if (CreateRootControl (FRAME_MAC_WINDOW (f), &root_control) != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1846 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1847 DisposeWindow (FRAME_MAC_WINDOW (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1848 FRAME_MAC_WINDOW (f) = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1849 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1850 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1851 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1852 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1853
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1854 /* Dispose of the Mac window of the frame F. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1855
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1856 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1857 mac_dispose_frame_window (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1858 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1859 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1860 WindowRef window = FRAME_MAC_WINDOW (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1861
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1862 if (window != tip_window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1863 remove_window_handler (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1864
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1865 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1866 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1867 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1868 DisposeWindow (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1869 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1870
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1871
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1872 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1873 View and Drawing
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1874 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1875
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1876 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1877 #define FRAME_CG_CONTEXT(f) ((f)->output_data.mac->cg_context)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1878
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1879 CGContextRef
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1880 mac_begin_cg_clip (f, gc)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1881 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1882 GC gc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1883 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1884 CGContextRef context = FRAME_CG_CONTEXT (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1885
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1886 if (!context)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1887 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1888 QDBeginCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)), &context);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1889 FRAME_CG_CONTEXT (f) = context;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1890 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1891
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1892 CGContextSaveGState (context);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1893 CGContextTranslateCTM (context, 0, FRAME_PIXEL_HEIGHT (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1894 CGContextScaleCTM (context, 1, -1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1895 if (gc && gc->n_clip_rects)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1896 CGContextClipToRects (context, gc->clip_rects, gc->n_clip_rects);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1897
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1898 return context;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1899 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1900
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1901 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1902 mac_end_cg_clip (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1903 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1904 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1905 CGContextRestoreGState (FRAME_CG_CONTEXT (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1906 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1907
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1908 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1909 mac_prepare_for_quickdraw (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1910 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1911 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1912 if (f == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1913 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1914 Lisp_Object rest, frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1915 FOR_EACH_FRAME (rest, frame)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1916 if (FRAME_MAC_P (XFRAME (frame)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1917 mac_prepare_for_quickdraw (XFRAME (frame));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1918 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1919 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1920 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1921 CGContextRef context = FRAME_CG_CONTEXT (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1922
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1923 if (context)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1924 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1925 CGContextSynchronize (context);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1926 QDEndCGContext (GetWindowPort (FRAME_MAC_WINDOW (f)),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1927 &FRAME_CG_CONTEXT (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1928 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1929 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1930 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1931 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1932
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1933 static RgnHandle saved_port_clip_region = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1934
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1935 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1936 mac_begin_clip (f, gc)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1937 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1938 GC gc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1939 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1940 static RgnHandle new_region = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1941
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1942 if (saved_port_clip_region == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1943 saved_port_clip_region = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1944 if (new_region == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1945 new_region = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1946
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1947 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1948 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1949 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1950 SetPortWindowPort (FRAME_MAC_WINDOW (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1951
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1952 if (gc && gc->n_clip_rects)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1953 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1954 GetClip (saved_port_clip_region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1955 SectRgn (saved_port_clip_region, gc->clip_region, new_region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1956 SetClip (new_region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1957 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1958 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1959
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1960 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1961 mac_end_clip (f, gc)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1962 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1963 GC gc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1964 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1965 if (gc && gc->n_clip_rects)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1966 SetClip (saved_port_clip_region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1967 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1968
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1969 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1970 /* Mac replacement for XCopyArea: used only for scrolling. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1971
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1972 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1973 mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1974 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1975 GC gc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1976 int src_x, src_y;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1977 unsigned int width, height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1978 int dest_x, dest_y;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1979 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1980 Rect src_r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1981 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1982
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1983 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1984 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1985 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1986 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1987 ScrollWindowRect (FRAME_MAC_WINDOW (f),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1988 &src_r, dest_x - src_x, dest_y - src_y,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1989 kScrollWindowNoOptions, dummy);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1990 DisposeRgn (dummy);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1991 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1992 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1993
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1994
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1995 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1996 Scroll bars
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1997 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1998
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1999 extern struct scroll_bar *tracked_scroll_bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2000 extern Lisp_Object last_mouse_scroll_bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2001 extern Time last_mouse_movement_time;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2002
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2003 static void x_scroll_bar_handle_click P_ ((struct scroll_bar *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2004 ControlPartCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2005 const EventRecord *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2006 struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2007 #ifndef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2008 static void x_scroll_bar_note_movement P_ ((struct scroll_bar *, int, Time));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2009 #else /* USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2010 static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2011 ControlPartCode, Point,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2012 struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2013 static void x_scroll_bar_handle_release P_ ((struct scroll_bar *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2014 struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2015 static void x_scroll_bar_handle_drag P_ ((WindowRef, struct scroll_bar *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2016 Point, struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2017 static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2018 static OSStatus install_scroll_bar_timer P_ ((void));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2019 static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2020 static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2021 static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2022 struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2023 static OSStatus get_control_part_bounds P_ ((ControlRef, ControlPartCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2024 Rect *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2025 static void update_scroll_bar_track_info P_ ((struct scroll_bar *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2026
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2027 /* Last scroll bar part sent in x_scroll_bar_handle_*. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2028
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2029 static int last_scroll_bar_part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2030
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2031 static EventLoopTimerRef scroll_bar_timer;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2032
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2033 static int scroll_bar_timer_event_posted_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2034
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2035 #define SCROLL_BAR_FIRST_DELAY 0.5
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2036 #define SCROLL_BAR_CONTINUOUS_DELAY (1.0 / 15)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2037
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2038 static pascal void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2039 scroll_bar_timer_callback (timer, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2040 EventLoopTimerRef timer;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2041 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2042 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2043 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2044
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2045 err = mac_post_mouse_moved_event ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2046 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2047 scroll_bar_timer_event_posted_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2048 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2049
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2050 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2051 install_scroll_bar_timer ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2052 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2053 static EventLoopTimerUPP scroll_bar_timer_callbackUPP = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2054
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2055 if (scroll_bar_timer_callbackUPP == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2056 scroll_bar_timer_callbackUPP =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2057 NewEventLoopTimerUPP (scroll_bar_timer_callback);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2058
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2059 if (scroll_bar_timer == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2060 /* Mac OS X and CarbonLib 1.5 and later allow us to specify
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2061 kEventDurationForever as delays. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2062 return
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2063 InstallEventLoopTimer (GetCurrentEventLoop (),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2064 kEventDurationForever, kEventDurationForever,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2065 scroll_bar_timer_callbackUPP, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2066 &scroll_bar_timer);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2067 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2068
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2069 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2070 set_scroll_bar_timer (delay)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2071 EventTimerInterval delay;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2072 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2073 if (scroll_bar_timer == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2074 install_scroll_bar_timer ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2075
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2076 scroll_bar_timer_event_posted_p = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2077
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2078 return SetEventLoopTimerNextFireTime (scroll_bar_timer, delay);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2079 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2080
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2081 static int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2082 control_part_code_to_scroll_bar_part (part_code)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2083 ControlPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2084 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2085 switch (part_code)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2086 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2087 case kControlUpButtonPart: return scroll_bar_up_arrow;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2088 case kControlDownButtonPart: return scroll_bar_down_arrow;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2089 case kControlPageUpPart: return scroll_bar_above_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2090 case kControlPageDownPart: return scroll_bar_below_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2091 case kControlIndicatorPart: return scroll_bar_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2092 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2093
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2094 return -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2095 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2096
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2097 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2098 construct_scroll_bar_click (bar, part, bufp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2099 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2100 int part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2101 struct input_event *bufp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2102 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2103 bufp->kind = SCROLL_BAR_CLICK_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2104 bufp->frame_or_window = bar->window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2105 bufp->arg = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2106 bufp->part = part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2107 bufp->code = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2108 XSETINT (bufp->x, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2109 XSETINT (bufp->y, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2110 bufp->modifiers = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2111 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2112
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2113 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2114 get_control_part_bounds (ch, part_code, rect)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2115 ControlRef ch;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2116 ControlPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2117 Rect *rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2118 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2119 RgnHandle region = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2120 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2121
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2122 err = GetControlRegion (ch, part_code, region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2123 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2124 GetRegionBounds (region, rect);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2125 DisposeRgn (region);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2126
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2127 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2128 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2129
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2130 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2131 x_scroll_bar_handle_press (bar, part_code, mouse_pos, bufp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2132 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2133 ControlPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2134 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2135 struct input_event *bufp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2136 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2137 int part = control_part_code_to_scroll_bar_part (part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2138
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2139 if (part < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2140 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2141
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2142 if (part != scroll_bar_handle)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2143 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2144 construct_scroll_bar_click (bar, part, bufp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2145 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2146 set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2147 bar->dragging = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2148 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2149 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2150 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2151 Rect r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2152
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2153 get_control_part_bounds (SCROLL_BAR_CONTROL_REF (bar),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2154 kControlIndicatorPart, &r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2155 XSETINT (bar->dragging, - (mouse_pos.v - r.top) - 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2156 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2157
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2158 last_scroll_bar_part = part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2159 tracked_scroll_bar = bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2160 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2161
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2162 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2163 x_scroll_bar_handle_release (bar, bufp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2164 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2165 struct input_event *bufp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2166 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2167 if (last_scroll_bar_part != scroll_bar_handle
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2168 || (INTEGERP (bar->dragging) && XINT (bar->dragging) >= 0))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2169 construct_scroll_bar_click (bar, scroll_bar_end_scroll, bufp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2170
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2171 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2172 set_scroll_bar_timer (kEventDurationForever);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2173
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2174 last_scroll_bar_part = -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2175 bar->dragging = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2176 tracked_scroll_bar = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2177 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2178
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2179 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2180 x_scroll_bar_handle_drag (win, bar, mouse_pos, bufp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2181 WindowRef win;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2182 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2183 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2184 struct input_event *bufp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2185 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2186 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2187
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2188 if (last_scroll_bar_part == scroll_bar_handle)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2189 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2190 int top, top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2191 Rect r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2192
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2193 get_control_part_bounds (SCROLL_BAR_CONTROL_REF (bar),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2194 kControlIndicatorPart, &r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2195
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2196 if (INTEGERP (bar->dragging) && XINT (bar->dragging) < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2197 XSETINT (bar->dragging, - (XINT (bar->dragging) + 1));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2198
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2199 top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2200 top_range = XINT (bar->track_height) - XINT (bar->min_handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2201
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2202 if (top < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2203 top = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2204 if (top > top_range)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2205 top = top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2206
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2207 construct_scroll_bar_click (bar, scroll_bar_handle, bufp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2208 XSETINT (bufp->x, top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2209 XSETINT (bufp->y, top_range);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2210 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2211 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2212 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2213 ControlPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2214 int unhilite_p = 0, part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2215
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2216 if (ch != FindControlUnderMouse (mouse_pos, win, &part_code))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2217 unhilite_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2218 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2219 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2220 part = control_part_code_to_scroll_bar_part (part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2221
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2222 switch (last_scroll_bar_part)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2223 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2224 case scroll_bar_above_handle:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2225 case scroll_bar_below_handle:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2226 if (part != scroll_bar_above_handle
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2227 && part != scroll_bar_below_handle)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2228 unhilite_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2229 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2230
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2231 case scroll_bar_up_arrow:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2232 case scroll_bar_down_arrow:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2233 if (part != scroll_bar_up_arrow
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2234 && part != scroll_bar_down_arrow)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2235 unhilite_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2236 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2237 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2238 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2239
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2240 if (unhilite_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2241 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2242 else if (part != last_scroll_bar_part
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2243 || scroll_bar_timer_event_posted_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2244 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2245 construct_scroll_bar_click (bar, part, bufp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2246 last_scroll_bar_part = part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2247 HiliteControl (SCROLL_BAR_CONTROL_REF (bar), part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2248 set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2249 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2250 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2251 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2252
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2253 /* Update BAR->track_top, BAR->track_height, and BAR->min_handle for
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2254 the scroll bar BAR. This function should be called when the bounds
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2255 of the scroll bar is changed. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2256
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2257 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2258 update_scroll_bar_track_info (bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2259 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2260 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2261 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2262 Rect r0, r1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2263
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2264 GetControlBounds (ch, &r0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2265
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2266 if (r0.right - r0.left >= r0.bottom - r0.top
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2267 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2268 || r0.right - r0.left < MAC_AQUA_SMALL_VERTICAL_SCROLL_BAR_WIDTH
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2269 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2270 )
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2271 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2272 XSETINT (bar->track_top, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2273 XSETINT (bar->track_height, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2274 XSETINT (bar->min_handle, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2275 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2276 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2277 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2278 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2279
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2280 SetControl32BitMinimum (ch, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2281 SetControl32BitMaximum (ch, 1 << 30);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2282 SetControlViewSize (ch, 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2283
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2284 /* Move the scroll bar thumb to the top. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2285 SetControl32BitValue (ch, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2286 get_control_part_bounds (ch, kControlIndicatorPart, &r0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2287
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2288 /* Move the scroll bar thumb to the bottom. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2289 SetControl32BitValue (ch, 1 << 30);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2290 get_control_part_bounds (ch, kControlIndicatorPart, &r1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2291
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2292 UnionRect (&r0, &r1, &r0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2293 XSETINT (bar->track_top, r0.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2294 XSETINT (bar->track_height, r0.bottom - r0.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2295 XSETINT (bar->min_handle, r1.bottom - r1.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2296
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2297 /* Don't show the scroll bar if its height is not enough to
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2298 display the scroll bar thumb. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2299 if (r0.bottom - r0.top > 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2300 ShowControl (ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2301
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2302 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2303 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2304 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2305
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2306 /* Set the thumb size and position of scroll bar BAR. We are currently
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2307 displaying PORTION out of a whole WHOLE, and our position POSITION. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2308
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2309 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2310 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2311 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2312 int portion, position, whole;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2313 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2314 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2315 int value, viewsize, maximum;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2316
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2317 if (XINT (bar->track_height) == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2318 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2319
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2320 if (whole <= portion)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2321 value = 0, viewsize = 1, maximum = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2322 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2323 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2324 float scale;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2325
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2326 maximum = XINT (bar->track_height) - XINT (bar->min_handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2327 scale = (float) maximum / (whole - portion);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2328 value = position * scale + 0.5f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2329 viewsize = (int) (portion * scale + 0.5f) + XINT (bar->min_handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2330 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2331
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2332 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2333
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2334 if (GetControlViewSize (ch) != viewsize
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2335 || GetControl32BitValue (ch) != value
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2336 || GetControl32BitMaximum (ch) != maximum)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2337 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2338 /* Temporarily hide the scroll bar to avoid multiple redraws. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2339 SetControlVisibility (ch, false, false);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2340
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2341 SetControl32BitMaximum (ch, maximum);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2342 SetControl32BitValue (ch, value);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2343 SetControlViewSize (ch, viewsize);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2344
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2345 SetControlVisibility (ch, true, true);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2346 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2347
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2348 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2349 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2350
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2351 #endif /* USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2352
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2353 /* Create a scroll bar control for BAR. BOUNDS and VISIBLE specifies
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2354 the initial geometry and visibility, respectively. The created
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2355 control is stored in some members of BAR. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2356
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2357 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2358 mac_create_scroll_bar (bar, bounds, visible)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2359 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2360 const Rect *bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2361 Boolean visible;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2362 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2363 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2364 ControlRef ch;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2365
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2366 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2367 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2368 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2369 ch = NewControl (FRAME_MAC_WINDOW (f), bounds, "\p", visible, 0, 0, 0,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2370 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2371 kControlScrollBarProc,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2372 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2373 scrollBarProc,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2374 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2375 (SInt32) bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2376 SET_SCROLL_BAR_CONTROL_REF (bar, ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2377
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2378 XSETINT (bar->start, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2379 XSETINT (bar->end, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2380 bar->dragging = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2381
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2382 #ifdef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2383 update_scroll_bar_track_info (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2384 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2385 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2386
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2387 /* Dispose of the scroll bar control stored in some members of
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2388 BAR. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2389
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2390 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2391 mac_dispose_scroll_bar (bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2392 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2393 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2394 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2395 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2396
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2397 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2398 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2399 DisposeControl (SCROLL_BAR_CONTROL_REF (bar));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2400 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2401
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2402 /* Set bounds of the scroll bar BAR to BOUNDS. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2403
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2404 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2405 mac_set_scroll_bar_bounds (bar, bounds)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2406 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2407 const Rect *bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2408 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2409 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2410 SInt16 width, height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2411 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2412 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2413
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2414 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2415 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2416
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2417 width = bounds->right - bounds->left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2418 height = bounds->bottom - bounds->top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2419 HideControl (ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2420 MoveControl (ch, bounds->left, bounds->top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2421 SizeControl (ch, width, height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2422 #ifdef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2423 update_scroll_bar_track_info (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2424 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2425 if (width < height)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2426 ShowControl (ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2427 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2428 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2429
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2430 /* Draw the scroll bar BAR. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2431
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2432 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2433 mac_redraw_scroll_bar (bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2434 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2435 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2436 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2437 struct frame *f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2438
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2439 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2440 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2441 Draw1Control (SCROLL_BAR_CONTROL_REF (bar));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2442 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2443
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2444 /* Handle a mouse click on the scroll bar BAR. If *EMACS_EVENT's kind
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2445 is set to something other than NO_EVENT, it is enqueued.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2447 This may be called from a signal handler, so we have to ignore GC
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2448 mark bits. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2449
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2450 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2451 x_scroll_bar_handle_click (bar, part_code, er, bufp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2452 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2453 ControlPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2454 const EventRecord *er;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2455 struct input_event *bufp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2456 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2457 int win_y, top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2458
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2459 if (! GC_WINDOWP (bar->window))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2460 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2461
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2462 bufp->kind = SCROLL_BAR_CLICK_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2463 bufp->frame_or_window = bar->window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2464 bufp->arg = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2465
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2466 bar->dragging = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2467
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2468 switch (part_code)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2469 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2470 case kControlUpButtonPart:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2471 bufp->part = scroll_bar_up_arrow;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2472 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2473 case kControlDownButtonPart:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2474 bufp->part = scroll_bar_down_arrow;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2475 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2476 case kControlPageUpPart:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2477 bufp->part = scroll_bar_above_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2478 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2479 case kControlPageDownPart:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2480 bufp->part = scroll_bar_below_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2481 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2482 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2483 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2484 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2485 case kControlIndicatorPart:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2486 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2487 if (er->what == mouseDown)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2488 bar->dragging = make_number (0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2489 XSETVECTOR (last_mouse_scroll_bar, bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2490 bufp->part = scroll_bar_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2491 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2492 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2493
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2494 win_y = XINT (bufp->y) - XINT (bar->top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2495 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2496
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2497 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2498
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2499 win_y -= 24;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2500
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2501 if (! NILP (bar->dragging))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2502 win_y -= XINT (bar->dragging);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2503
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2504 if (win_y < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2505 win_y = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2506 if (win_y > top_range)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2507 win_y = top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2508
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2509 XSETINT (bufp->x, win_y);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2510 XSETINT (bufp->y, top_range);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2511 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2512
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2513 /* Return information to the user about the current position of the mouse
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2514 on the scroll bar. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2515
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2516 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2517 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2518 FRAME_PTR *fp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2519 Lisp_Object *bar_window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2520 enum scroll_bar_part *part;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2521 Lisp_Object *x, *y;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2522 unsigned long *time;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2523 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2524 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2525 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2526 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2527 WindowRef wp = GetControlOwner (ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2528 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2529 WindowRef wp = (*ch)->contrlOwner;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2530 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2531 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2532 struct frame *f = mac_window_to_frame (wp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2533 int win_y, top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2534
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2535 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2536 GetGlobalMouse (&mouse_pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2537 mouse_pos.h -= f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2538 mouse_pos.v -= f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2539 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2540 SetPortWindowPort (wp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2541 GetMouse (&mouse_pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2542 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2543
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2544 win_y = mouse_pos.v - XINT (bar->top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2545 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2546
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2547 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2548
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2549 win_y -= 24;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2550
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2551 if (! NILP (bar->dragging))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2552 win_y -= XINT (bar->dragging);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2553
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2554 if (win_y < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2555 win_y = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2556 if (win_y > top_range)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2557 win_y = top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2558
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2559 *fp = f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2560 *bar_window = bar->window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2561
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2562 if (! NILP (bar->dragging))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2563 *part = scroll_bar_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2564 else if (win_y < XINT (bar->start))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2565 *part = scroll_bar_above_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2566 else if (win_y < XINT (bar->end) + VERTICAL_SCROLL_BAR_MIN_HANDLE)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2567 *part = scroll_bar_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2568 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2569 *part = scroll_bar_below_handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2570
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2571 XSETINT (*x, win_y);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2572 XSETINT (*y, top_range);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2573
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2574 f->mouse_moved = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2575 last_mouse_scroll_bar = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2576
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2577 *time = last_mouse_movement_time;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2578 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2579
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2580 #ifndef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2581 /* Draw BAR's handle in the proper position.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2582
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2583 If the handle is already drawn from START to END, don't bother
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2584 redrawing it, unless REBUILD is non-zero; in that case, always
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2585 redraw it. (REBUILD is handy for drawing the handle after expose
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2586 events.)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2587
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2588 Normally, we want to constrain the start and end of the handle to
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2589 fit inside its rectangle, but if the user is dragging the scroll
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2590 bar handle, we want to let them drag it down all the way, so that
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2591 the bar's top is as far down as it goes; otherwise, there's no way
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2592 to move to the very end of the buffer. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2593
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2594 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2595 x_scroll_bar_set_handle (bar, start, end, rebuild)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2596 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2597 int start, end;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2598 int rebuild;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2599 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2600 int dragging = ! NILP (bar->dragging);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2601 ControlRef ch = SCROLL_BAR_CONTROL_REF (bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2602 FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (bar->window)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2603 int top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2604 int length = end - start;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2605
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2606 /* If the display is already accurate, do nothing. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2607 if (! rebuild
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2608 && start == XINT (bar->start)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2609 && end == XINT (bar->end))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2610 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2611
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2612 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2613
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2614 /* Make sure the values are reasonable, and try to preserve the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2615 distance between start and end. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2616 if (start < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2617 start = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2618 else if (start > top_range)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2619 start = top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2620 end = start + length;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2621
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2622 if (end < start)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2623 end = start;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2624 else if (end > top_range && ! dragging)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2625 end = top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2626
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2627 /* Store the adjusted setting in the scroll bar. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2628 XSETINT (bar->start, start);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2629 XSETINT (bar->end, end);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2630
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2631 /* Clip the end position, just for display. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2632 if (end > top_range)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2633 end = top_range;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2634
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2635 /* Draw bottom positions VERTICAL_SCROLL_BAR_MIN_HANDLE pixels below
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2636 top positions, to make sure the handle is always at least that
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2637 many pixels tall. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2638 end += VERTICAL_SCROLL_BAR_MIN_HANDLE;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2639
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2640 SetControlMinimum (ch, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2641 /* Don't inadvertently activate deactivated scroll bars */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2642 if (GetControlMaximum (ch) != -1)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2643 SetControlMaximum (ch, top_range + VERTICAL_SCROLL_BAR_MIN_HANDLE
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2644 - (end - start));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2645 SetControlValue (ch, start);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2646 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2647 SetControlViewSize (ch, end - start);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2648 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2649
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2650 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2651 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2652
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2653 /* Handle some mouse motion while someone is dragging the scroll bar.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2654
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2655 This may be called from a signal handler, so we have to ignore GC
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2656 mark bits. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2657
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2658 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2659 x_scroll_bar_note_movement (bar, y_pos, t)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2660 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2661 int y_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2662 Time t;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2663 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2664 FRAME_PTR f = XFRAME (XWINDOW (bar->window)->frame);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2665
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2666 last_mouse_movement_time = t;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2667
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2668 f->mouse_moved = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2669 XSETVECTOR (last_mouse_scroll_bar, bar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2670
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2671 /* If we're dragging the bar, display it. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2672 if (! GC_NILP (bar->dragging))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2673 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2674 /* Where should the handle be now? */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2675 int new_start = y_pos - 24;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2676
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2677 if (new_start != XINT (bar->start))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2678 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2679 int new_end = new_start + (XINT (bar->end) - XINT (bar->start));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2680
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2681 x_scroll_bar_set_handle (bar, new_start, new_end, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2682 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2683 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2684 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2685 #endif /* !USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2686
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2687
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2688 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2689 Tool-bars
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2690 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2691
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2692 #if USE_MAC_TOOLBAR
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2693 /* In identifiers such as function/variable names, Emacs tool bar is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2694 referred to as `tool_bar', and Carbon HIToolbar as `toolbar'. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2695
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2696 #define TOOLBAR_IDENTIFIER (CFSTR ("org.gnu.Emacs.toolbar"))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2697 #define TOOLBAR_ICON_ITEM_IDENTIFIER (CFSTR ("org.gnu.Emacs.toolbar.icon"))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2698
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2699 #define TOOLBAR_ITEM_COMMAND_ID_OFFSET 'Tb\0\0'
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2700 #define TOOLBAR_ITEM_COMMAND_ID_P(id) \
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2701 (((id) & ~0xffff) == TOOLBAR_ITEM_COMMAND_ID_OFFSET)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2702 #define TOOLBAR_ITEM_COMMAND_ID_VALUE(id) \
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2703 ((id) - TOOLBAR_ITEM_COMMAND_ID_OFFSET)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2704 #define TOOLBAR_ITEM_MAKE_COMMAND_ID(value) \
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2705 ((value) + TOOLBAR_ITEM_COMMAND_ID_OFFSET)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2706
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2707 static OSStatus mac_handle_toolbar_command_event P_ ((EventHandlerCallRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2708 EventRef, void *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2709
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2710 extern Rect last_mouse_glyph;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2711
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2712 extern void mac_move_window_with_gravity P_ ((struct frame *, int,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2713 short, short));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2714 extern void mac_get_window_origin_with_gravity P_ ((struct frame *, int,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2715 short *, short *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2716 extern CGImageRef mac_image_spec_to_cg_image P_ ((struct frame *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2717 Lisp_Object));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2718
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2719 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2720 mac_handle_toolbar_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2721 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2722 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2723 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2724 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2725 OSStatus result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2726
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2727 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2728 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2729 case kEventToolbarGetDefaultIdentifiers:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2730 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2731 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2732
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2733 case kEventToolbarGetAllowedIdentifiers:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2734 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2735 CFMutableArrayRef array;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2736
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2737 GetEventParameter (event, kEventParamMutableArray,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2738 typeCFMutableArrayRef, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2739 sizeof (CFMutableArrayRef), NULL, &array);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2740 CFArrayAppendValue (array, TOOLBAR_ICON_ITEM_IDENTIFIER);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2741 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2742 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2743 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2744
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2745 case kEventToolbarCreateItemWithIdentifier:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2746 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2747 CFStringRef identifier;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2748 HIToolbarItemRef item = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2749
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2750 GetEventParameter (event, kEventParamToolbarItemIdentifier,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2751 typeCFStringRef, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2752 sizeof (CFStringRef), NULL, &identifier);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2753
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2754 if (CFStringCompare (identifier, TOOLBAR_ICON_ITEM_IDENTIFIER, 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2755 == kCFCompareEqualTo)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2756 HIToolbarItemCreate (identifier,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2757 kHIToolbarItemAllowDuplicates
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2758 | kHIToolbarItemCantBeRemoved, &item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2759
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2760 if (item)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2761 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2762 SetEventParameter (event, kEventParamToolbarItem,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2763 typeHIToolbarItemRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2764 sizeof (HIToolbarItemRef), &item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2765 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2766 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2767 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2768 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2769
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2770 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2771 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2772 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2773
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2774 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2775 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2776
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2777 /* Create a tool bar for frame F. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2778
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2779 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2780 mac_create_frame_tool_bar (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2781 FRAME_PTR f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2782 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2783 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2784 HIToolbarRef toolbar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2785
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2786 err = HIToolbarCreate (TOOLBAR_IDENTIFIER, kHIToolbarNoAttributes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2787 &toolbar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2788 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2789 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2790 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2791 {{kEventClassToolbar, kEventToolbarGetDefaultIdentifiers},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2792 {kEventClassToolbar, kEventToolbarGetAllowedIdentifiers},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2793 {kEventClassToolbar, kEventToolbarCreateItemWithIdentifier}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2794
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2795 err = InstallEventHandler (HIObjectGetEventTarget (toolbar),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2796 mac_handle_toolbar_event,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2797 GetEventTypeCount (specs), specs,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2798 f, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2799 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2800
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2801 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2802 err = HIToolbarSetDisplayMode (toolbar, kHIToolbarDisplayModeIconOnly);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2803 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2804 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2805 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2806 {{kEventClassCommand, kEventCommandProcess}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2807
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2808 err = InstallWindowEventHandler (FRAME_MAC_WINDOW (f),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2809 mac_handle_toolbar_command_event,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2810 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2811 specs, f, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2812 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2813 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2814 err = SetWindowToolbar (FRAME_MAC_WINDOW (f), toolbar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2815
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2816 if (toolbar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2817 CFRelease (toolbar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2818
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2819 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2820 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2821
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2822 /* Update the tool bar for frame F. Add new buttons and remove old. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2823
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2824 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2825 update_frame_tool_bar (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2826 FRAME_PTR f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2827 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2828 HIToolbarRef toolbar = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2829 short left, top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2830 CFArrayRef old_items = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2831 CFIndex old_count;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2832 int i, pos, win_gravity = f->output_data.mac->toolbar_win_gravity;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2833 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2834
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2835 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2836
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2837 GetWindowToolbar (FRAME_MAC_WINDOW (f), &toolbar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2838 if (toolbar == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2839 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2840 mac_create_frame_tool_bar (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2841 GetWindowToolbar (FRAME_MAC_WINDOW (f), &toolbar);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2842 if (toolbar == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2843 goto out;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2844 if (win_gravity >= NorthWestGravity && win_gravity <= SouthEastGravity)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2845 mac_get_window_origin_with_gravity (f, win_gravity, &left, &top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2846 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2847
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2848 HIToolbarCopyItems (toolbar, &old_items);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2849 if (old_items == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2850 goto out;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2851
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2852 old_count = CFArrayGetCount (old_items);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2853 pos = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2854 for (i = 0; i < f->n_tool_bar_items; ++i)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2855 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2856 #define PROP(IDX) AREF (f->tool_bar_items, i * TOOL_BAR_ITEM_NSLOTS + (IDX))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2857
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2858 int enabled_p = !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2859 int selected_p = !NILP (PROP (TOOL_BAR_ITEM_SELECTED_P));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2860 int idx;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2861 Lisp_Object image;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2862 CGImageRef cg_image;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2863 CFStringRef label;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2864 HIToolbarItemRef item;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2865
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2866 /* If image is a vector, choose the image according to the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2867 button state. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2868 image = PROP (TOOL_BAR_ITEM_IMAGES);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2869 if (VECTORP (image))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2870 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2871 if (enabled_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2872 idx = (selected_p
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2873 ? TOOL_BAR_IMAGE_ENABLED_SELECTED
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2874 : TOOL_BAR_IMAGE_ENABLED_DESELECTED);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2875 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2876 idx = (selected_p
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2877 ? TOOL_BAR_IMAGE_DISABLED_SELECTED
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2878 : TOOL_BAR_IMAGE_DISABLED_DESELECTED);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2879
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2880 xassert (ASIZE (image) >= idx);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2881 image = AREF (image, idx);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2882 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2883 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2884 idx = -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2885
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2886 cg_image = mac_image_spec_to_cg_image (f, image);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2887 /* Ignore invalid image specifications. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2888 if (cg_image == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2889 continue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2890
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2891 label = cfstring_create_with_string (PROP (TOOL_BAR_ITEM_CAPTION));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2892 if (label == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2893 label = CFSTR ("");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2894
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2895 if (pos < old_count)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2896 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2897 CGImageRef old_cg_image = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2898 CFStringRef old_label = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2899 Boolean old_enabled_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2900
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2901 item = (HIToolbarItemRef) CFArrayGetValueAtIndex (old_items, pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2902
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2903 HIToolbarItemCopyImage (item, &old_cg_image);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2904 if (cg_image != old_cg_image)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2905 HIToolbarItemSetImage (item, cg_image);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2906 CGImageRelease (old_cg_image);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2907
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2908 HIToolbarItemCopyLabel (item, &old_label);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2909 if (CFStringCompare (label, old_label, 0) != kCFCompareEqualTo)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2910 HIToolbarItemSetLabel (item, label);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2911 CFRelease (old_label);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2912
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2913 old_enabled_p = HIToolbarItemIsEnabled (item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2914 if ((enabled_p || idx >= 0) != old_enabled_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2915 HIToolbarItemSetEnabled (item, (enabled_p || idx >= 0));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2916 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2917 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2918 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2919 item = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2920 HIToolbarCreateItemWithIdentifier (toolbar,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2921 TOOLBAR_ICON_ITEM_IDENTIFIER,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2922 NULL, &item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2923 if (item)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2924 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2925 HIToolbarItemSetImage (item, cg_image);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2926 HIToolbarItemSetLabel (item, label);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2927 HIToolbarItemSetEnabled (item, (enabled_p || idx >= 0));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2928 HIToolbarAppendItem (toolbar, item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2929 CFRelease (item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2930 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2931 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2932
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2933 CFRelease (label);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2934 if (item)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2935 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2936 HIToolbarItemSetCommandID (item, TOOLBAR_ITEM_MAKE_COMMAND_ID (i));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2937 pos++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2938 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2939 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2940
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2941 CFRelease (old_items);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2942
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2943 while (pos < old_count)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2944 HIToolbarRemoveItemAtIndex (toolbar, --old_count);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2945
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2946 ShowHideWindowToolbar (FRAME_MAC_WINDOW (f), true,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2947 !win_gravity && f == mac_focus_frame (dpyinfo));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2948 /* Mac OS X 10.3 does not issue kEventWindowBoundsChanged events on
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2949 toolbar visibility change. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2950 mac_handle_origin_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2951 if (win_gravity >= NorthWestGravity && win_gravity <= SouthEastGravity)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2952 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2953 mac_move_window_with_gravity (f, win_gravity, left, top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2954 /* If the title bar is completely outside the screen, adjust the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2955 position. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2956 ConstrainWindowToScreen (FRAME_MAC_WINDOW (f), kWindowTitleBarRgn,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2957 kWindowConstrainMoveRegardlessOfFit
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2958 | kWindowConstrainAllowPartial, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2959 f->output_data.mac->toolbar_win_gravity = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2960 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2961
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2962 out:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2963 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2964 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2965
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2966 /* Hide the tool bar on frame F. Unlike the counterpart on GTK+, it
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2967 doesn't deallocate the resources. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2968
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2969 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2970 free_frame_tool_bar (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2971 FRAME_PTR f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2972 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2973 if (IsWindowToolbarVisible (FRAME_MAC_WINDOW (f)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2974 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2975 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2976
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2977 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2978 ShowHideWindowToolbar (FRAME_MAC_WINDOW (f), false,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2979 (NILP (find_symbol_value
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2980 (intern ("frame-notice-user-settings")))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2981 && f == mac_focus_frame (dpyinfo)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2982 /* Mac OS X 10.3 does not issue kEventWindowBoundsChanged events
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2983 on toolbar visibility change. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2984 mac_handle_origin_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2985 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2986 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2987 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2988
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2989 /* Report a mouse movement over toolbar to the mainstream Emacs
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2990 code. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2991
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2992 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2993 mac_tool_bar_note_mouse_movement (f, event)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2994 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2995 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2996 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2997 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2998 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
2999 int mouse_down_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3000 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3001 WindowPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3002 HIViewRef item_view;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3003 UInt32 command_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3004
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3005 mouse_down_p = (dpyinfo->grabbed
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3006 && f == last_mouse_frame
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3007 && FRAME_LIVE_P (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3008 if (mouse_down_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3009 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3010
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3011 err = GetEventParameter (event, kEventParamWindowRef, typeWindowRef, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3012 sizeof (WindowRef), NULL, &window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3013 if (err != noErr || window != FRAME_MAC_WINDOW (f))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3014 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3015
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3016 err = GetEventParameter (event, kEventParamWindowPartCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3017 typeWindowPartCode, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3018 sizeof (WindowPartCode), NULL, &part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3019 if (err != noErr || part_code != inStructure)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3020 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3021
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3022 err = HIViewGetViewForMouseEvent (HIViewGetRoot (window), event, &item_view);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3023 /* This doesn't work on Mac OS X 10.2. On Mac OS X 10.3 and 10.4, a
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3024 toolbar item view seems to have the same command ID with that of
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3025 the toolbar item. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3026 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3027 err = GetControlCommandID (item_view, &command_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3028 if (err == noErr && TOOLBAR_ITEM_COMMAND_ID_P (command_id))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3029 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3030 int i = TOOLBAR_ITEM_COMMAND_ID_VALUE (command_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3031
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3032 if (i < f->n_tool_bar_items)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3033 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3034 HIRect bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3035 HIViewRef content_view;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3036
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3037 err = HIViewGetBounds (item_view, &bounds);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3038 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3039 err = HIViewFindByID (HIViewGetRoot (window),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3040 kHIViewWindowContentID, &content_view);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3041 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3042 err = HIViewConvertRect (&bounds, item_view, content_view);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3043 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3044 SetRect (&last_mouse_glyph,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3045 CGRectGetMinX (bounds), CGRectGetMinY (bounds),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3046 CGRectGetMaxX (bounds), CGRectGetMaxY (bounds));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3047
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3048 help_echo_object = help_echo_window = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3049 help_echo_pos = -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3050 help_echo_string = PROP (TOOL_BAR_ITEM_HELP);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3051 if (NILP (help_echo_string))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3052 help_echo_string = PROP (TOOL_BAR_ITEM_CAPTION);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3053 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3054 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3055 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3056
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3057 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3058 mac_handle_toolbar_command_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3059 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3060 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3061 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3062 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3063 OSStatus err, result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3064 struct frame *f = (struct frame *) data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3065 HICommand command;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3066
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3067 err = GetEventParameter (event, kEventParamDirectObject,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3068 typeHICommand, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3069 sizeof (HICommand), NULL, &command);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3070 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3071 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3072
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3073 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3074 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3075 case kEventCommandProcess:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3076 if (!TOOLBAR_ITEM_COMMAND_ID_P (command.commandID))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3077 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3078 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3079 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3080 int i = TOOLBAR_ITEM_COMMAND_ID_VALUE (command.commandID);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3081
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3082 if (i < f->n_tool_bar_items
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3083 && !NILP (PROP (TOOL_BAR_ITEM_ENABLED_P)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3084 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3085 Lisp_Object frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3086 struct input_event buf;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3087
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3088 EVENT_INIT (buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3089
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3090 XSETFRAME (frame, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3091 buf.kind = TOOL_BAR_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3092 buf.frame_or_window = frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3093 buf.arg = frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3094 kbd_buffer_store_event (&buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3095
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3096 buf.kind = TOOL_BAR_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3097 buf.frame_or_window = frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3098 buf.arg = PROP (TOOL_BAR_ITEM_KEY);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3099 buf.modifiers = mac_event_to_emacs_modifiers (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3100 kbd_buffer_store_event (&buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3101
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3102 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3103 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3104 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3105 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3106
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3107 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3108 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3109 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3110 #undef PROP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3111
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3112 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3113 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3114 #endif /* USE_MAC_TOOLBAR */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3115
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3116
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3117 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3118 Font Panel
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3119 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3120
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3121 #if USE_MAC_FONT_PANEL
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3122 /* Whether Font Panel has been shown before. The first call to font
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3123 panel functions (FPIsFontPanelVisible, SetFontInfoForSelection) is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3124 slow. This variable is used for deferring such a call as much as
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3125 possible. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3126 static int font_panel_shown_p = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3127
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3128 extern Lisp_Object Qpanel_closed, Qselection;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3129 extern Lisp_Object Qfont;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3130
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3131 /* Whether the font panel is currently visible. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3132
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3133 int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3134 mac_font_panel_visible_p ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3135 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3136 return font_panel_shown_p && FPIsFontPanelVisible ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3137 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3138
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3139 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3140 mac_handle_font_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3141 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3142 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3143 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3144 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3145 OSStatus result, err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3146 Lisp_Object id_key;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3147 int num_params;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3148 const EventParamName *names;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3149 const EventParamType *types;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3150 static const EventParamName names_sel[] = {kEventParamATSUFontID,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3151 kEventParamATSUFontSize,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3152 kEventParamFMFontFamily,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3153 kEventParamFMFontStyle,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3154 kEventParamFMFontSize,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3155 kEventParamFontColor};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3156 static const EventParamType types_sel[] = {typeATSUFontID,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3157 typeATSUSize,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3158 typeFMFontFamily,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3159 typeFMFontStyle,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3160 typeFMFontSize,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3161 typeFontColor};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3162
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3163 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3164 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3165 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3166
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3167 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3168 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3169 case kEventFontPanelClosed:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3170 id_key = Qpanel_closed;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3171 num_params = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3172 names = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3173 types = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3174 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3175
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3176 case kEventFontSelection:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3177 id_key = Qselection;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3178 num_params = sizeof (names_sel) / sizeof (names_sel[0]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3179 names = names_sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3180 types = types_sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3181 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3182 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3183
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3184 err = mac_store_event_ref_as_apple_event (0, 0, Qfont, id_key,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3185 event, num_params,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3186 names, types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3187 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3188 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3189
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3190 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3191 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3192
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3193 /* Toggle visiblity of the font panel. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3194
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3195 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3196 mac_show_hide_font_panel ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3197 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3198 if (!font_panel_shown_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3199 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3200 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3201
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3202 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3203 {{kEventClassFont, kEventFontPanelClosed},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3204 {kEventClassFont, kEventFontSelection}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3205
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3206 err = InstallApplicationEventHandler (mac_handle_font_event,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3207 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3208 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3209 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3210 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3211
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3212 font_panel_shown_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3213 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3214
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3215 return FPShowHideFontPanel ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3216 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3217
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3218 /* Set the font selected in the font panel to the one corresponding to
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3219 the face FACE_ID and the charcacter C in the frame F. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3220
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3221 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3222 mac_set_font_info_for_selection (f, face_id, c)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3223 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3224 int face_id, c;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3225 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3226 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3227 EventTargetRef target = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3228 XFontStruct *font = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3229
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3230 if (!mac_font_panel_visible_p ())
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3231 return noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3232
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3233 if (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3234 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3235 target = GetWindowEventTarget (FRAME_MAC_WINDOW (f));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3236
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3237 if (FRAME_FACE_CACHE (f) && CHAR_VALID_P (c, 0))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3238 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3239 struct face *face;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3240
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3241 face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3242 face = FACE_FROM_ID (f, face_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3243 font = face->font;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3244 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3245 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3246
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3247 if (font == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3248 err = SetFontInfoForSelection (kFontSelectionATSUIType, 0, NULL, target);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3249 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3250 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3251 if (font->mac_fontnum != -1)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3252 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3253 FontSelectionQDStyle qd_style;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3254
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3255 qd_style.version = kFontSelectionQDStyleVersionZero;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3256 qd_style.instance.fontFamily = font->mac_fontnum;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3257 qd_style.instance.fontStyle = font->mac_fontface;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3258 qd_style.size = font->mac_fontsize;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3259 qd_style.hasColor = false;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3260
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3261 err = SetFontInfoForSelection (kFontSelectionQDType,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3262 1, &qd_style, target);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3263 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3264 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3265 err = SetFontInfoForSelection (kFontSelectionATSUIType,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3266 1, &font->mac_style, target);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3267 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3268
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3269 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3270 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3271 #endif /* USE_MAC_FONT_PANEL */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3272
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3273
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3274 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3275 Event Handling
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3276 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3277
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3278 /* Non-zero means that a HELP_EVENT has been generated since Emacs
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3279 start. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3280
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3281 static int any_help_event_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3282
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3283 /* Last window where we saw the mouse. Used by mouse-autoselect-window. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3284 static Lisp_Object last_window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3285
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3286 static Point saved_menu_event_location;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3287
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3288 extern struct frame *pending_autoraise_frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3289
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3290 extern FRAME_PTR last_mouse_glyph_frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3291
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3292 #ifdef __STDC__
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3293 extern int volatile input_signal_count;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3294 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3295 extern int input_signal_count;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3296 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3297
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3298 extern int mac_screen_config_changed;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3299
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3300 extern Lisp_Object Vmac_emulate_three_button_mouse;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3301 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3302 extern int mac_wheel_button_is_mouse_2;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3303 extern int mac_pass_command_to_system;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3304 extern int mac_pass_control_to_system;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3305 #endif /* TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3306 extern int mac_ready_for_apple_events;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3307
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3308 extern void mac_focus_changed P_ ((int, struct mac_display_info *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3309 struct frame *, struct input_event *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3310 extern int mac_get_emulated_btn P_ ((UInt32));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3311 extern int note_mouse_movement P_ ((FRAME_PTR, Point *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3312 extern void mac_get_screen_info P_ ((struct mac_display_info *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3313
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3314 /* The focus may have changed. Figure out if it is a real focus change,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3315 by checking both FocusIn/Out and Enter/LeaveNotify events.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3316
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3317 Returns FOCUS_IN_EVENT event in *BUFP. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3318
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3319 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3320 x_detect_focus_change (dpyinfo, event, bufp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3321 struct mac_display_info *dpyinfo;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3322 const EventRecord *event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3323 struct input_event *bufp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3324 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3325 struct frame *frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3326
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3327 frame = mac_window_to_frame ((WindowRef) event->message);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3328 if (! frame)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3329 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3330
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3331 /* On Mac, this is only called from focus events, so no switch needed. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3332 mac_focus_changed ((event->modifiers & activeFlag),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3333 dpyinfo, frame, bufp);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3334 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3335
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3336 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3337 /* Obtains the event modifiers from the event EVENTREF and then calls
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3338 mac_to_emacs_modifiers. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3339
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3340 static int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3341 mac_event_to_emacs_modifiers (EventRef eventRef)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3342 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3343 UInt32 mods = 0, class;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3344
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3345 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3346 sizeof (UInt32), NULL, &mods);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3347 class = GetEventClass (eventRef);
80517
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
3348 if (!NILP (Vmac_emulate_three_button_mouse)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
3349 && (class == kEventClassMouse || class == kEventClassCommand))
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3350 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3351 mods &= ~(optionKey | cmdKey);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3352 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3353 return mac_to_emacs_modifiers (mods, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3354 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3355
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3356 /* Given an event REF, return the code to use for the mouse button
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3357 code in the emacs input_event. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3358
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3359 static int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3360 mac_get_mouse_btn (EventRef ref)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3361 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3362 EventMouseButton result = kEventMouseButtonPrimary;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3363 GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3364 sizeof (EventMouseButton), NULL, &result);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3365 switch (result)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3366 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3367 case kEventMouseButtonPrimary:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3368 if (NILP (Vmac_emulate_three_button_mouse))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3369 return 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3370 else {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3371 UInt32 mods = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3372 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3373 sizeof (UInt32), NULL, &mods);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3374 return mac_get_emulated_btn(mods);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3375 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3376 case kEventMouseButtonSecondary:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3377 return mac_wheel_button_is_mouse_2 ? 2 : 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3378 case kEventMouseButtonTertiary:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3379 case 4: /* 4 is the number for the mouse wheel button */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3380 return mac_wheel_button_is_mouse_2 ? 1 : 2;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3381 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3382 return 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3383 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3384 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3385
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3386 /* Normally, ConvertEventRefToEventRecord will correctly handle all
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3387 events. However the click of the mouse wheel is not converted to a
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3388 mouseDown or mouseUp event. Likewise for dead key events. This
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3389 calls ConvertEventRefToEventRecord, but then checks to see if it is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3390 a mouse up/down, or a dead key Carbon event that has not been
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3391 converted, and if so, converts it by hand (to be picked up in the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3392 XTread_socket loop). */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3393 static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3394 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3395 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3396 Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3397 EventKind action;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3398
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3399 if (result)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3400 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3401
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3402 switch (GetEventClass (eventRef))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3403 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3404 case kEventClassMouse:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3405 switch (GetEventKind (eventRef))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3406 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3407 case kEventMouseDown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3408 eventRec->what = mouseDown;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3409 result = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3410 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3411
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3412 case kEventMouseUp:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3413 eventRec->what = mouseUp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3414 result = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3415 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3416
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3417 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3418 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3419 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3420 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3421
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3422 case kEventClassKeyboard:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3423 switch (GetEventKind (eventRef))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3424 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3425 case kEventRawKeyDown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3426 action = keyDown;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3427 goto keystroke_common;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3428 case kEventRawKeyRepeat:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3429 action = autoKey;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3430 goto keystroke_common;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3431 case kEventRawKeyUp:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3432 action = keyUp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3433 keystroke_common:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3434 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3435 unsigned char char_codes;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3436 UInt32 key_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3437
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3438 err = GetEventParameter (eventRef, kEventParamKeyMacCharCodes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3439 typeChar, NULL, sizeof (char),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3440 NULL, &char_codes);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3441 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3442 err = GetEventParameter (eventRef, kEventParamKeyCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3443 typeUInt32, NULL, sizeof (UInt32),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3444 NULL, &key_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3445 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3446 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3447 eventRec->what = action;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3448 eventRec->message = char_codes | ((key_code & 0xff) << 8);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3449 result = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3450 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3451 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3452 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3453
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3454 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3455 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3456 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3457 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3458
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3459 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3460 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3461 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3462
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3463 if (result)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3464 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3465 /* Need where and when. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3466 UInt32 mods = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3467
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3468 GetEventParameter (eventRef, kEventParamMouseLocation, typeQDPoint,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3469 NULL, sizeof (Point), NULL, &eventRec->where);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3470 /* Use two step process because new event modifiers are 32-bit
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3471 and old are 16-bit. Currently, only loss is NumLock & Fn. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3472 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3473 NULL, sizeof (UInt32), NULL, &mods);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3474 eventRec->modifiers = mods;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3475
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3476 eventRec->when = EventTimeToTicks (GetEventTime (eventRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3477 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3478
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3479 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3480 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3481 #endif /* TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3482
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3483 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3484 static RgnHandle mouse_region = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3485
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3486 Boolean
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3487 mac_wait_next_event (er, sleep_time, dequeue)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3488 EventRecord *er;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3489 UInt32 sleep_time;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3490 Boolean dequeue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3491 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3492 static EventRecord er_buf = {nullEvent};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3493 UInt32 target_tick, current_tick;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3494 EventMask event_mask;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3495
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3496 if (mouse_region == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3497 mouse_region = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3498
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3499 event_mask = everyEvent;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3500 if (!mac_ready_for_apple_events)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3501 event_mask -= highLevelEventMask;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3502
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3503 current_tick = TickCount ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3504 target_tick = current_tick + sleep_time;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3505
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3506 if (er_buf.what == nullEvent)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3507 while (!WaitNextEvent (event_mask, &er_buf,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3508 target_tick - current_tick, mouse_region))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3509 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3510 current_tick = TickCount ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3511 if (target_tick <= current_tick)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3512 return false;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3513 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3514
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3515 *er = er_buf;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3516 if (dequeue)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3517 er_buf.what = nullEvent;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3518 return true;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3519 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3520 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3521
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3522 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3523 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3524 mac_post_mouse_moved_event ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3525 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3526 EventRef event = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3527 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3528
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3529 err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3530 kEventAttributeNone, &event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3531 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3532 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3533 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3534
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3535 GetGlobalMouse (&mouse_pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3536 err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3537 sizeof (Point), &mouse_pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3538 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3539 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3540 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3541 UInt32 modifiers = GetCurrentKeyModifiers ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3542
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3543 err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3544 sizeof (UInt32), &modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3545 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3546 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3547 err = PostEventToQueue (GetCurrentEventQueue (), event,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3548 kEventPriorityStandard);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3549 if (event)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3550 ReleaseEvent (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3551
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3552 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3553 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3554 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3555
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3556 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3557 /* Run the current run loop in the default mode until some input
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3558 happens or TIMEOUT seconds passes unless it is negative. Return
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3559 true if timeout occurs first. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3560
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3561 Boolean
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3562 mac_run_loop_run_once (timeout)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3563 EventTimeout timeout;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3564 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3565 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3566 mac_prepare_for_quickdraw (NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3567 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3568 return (CFRunLoopRunInMode (kCFRunLoopDefaultMode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3569 timeout >= 0 ? timeout : 100000, true)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3570 == kCFRunLoopRunTimedOut);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3571 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3572 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3573
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3574 /* Emacs calls this whenever it wants to read an input event from the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3575 user. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3576
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3577 int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3578 XTread_socket (sd, expected, hold_quit)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3579 int sd, expected;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3580 struct input_event *hold_quit;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3581 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3582 struct input_event inev;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3583 int count = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3584 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3585 EventRef eventRef;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3586 EventTargetRef toolbox_dispatcher;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3587 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3588 EventRecord er;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3589 struct mac_display_info *dpyinfo = &one_mac_display_info;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3590
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3591 if (interrupt_input_blocked)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3592 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3593 interrupt_input_pending = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3594 return -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3595 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3596
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3597 interrupt_input_pending = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3598 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3599
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3600 /* So people can tell when we have read the available input. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3601 input_signal_count++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3602
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3603 ++handling_signal;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3604
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3605 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3606 toolbox_dispatcher = GetEventDispatcherTarget ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3607
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3608 while (
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3609 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3610 mac_prepare_for_quickdraw (NULL),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3611 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3612 !ReceiveNextEvent (0, NULL, kEventDurationNoWait,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3613 kEventRemoveFromQueue, &eventRef))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3614 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3615 while (mac_wait_next_event (&er, 0, true))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3616 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3617 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3618 int do_help = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3619 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3620 unsigned long timestamp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3621
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3622 EVENT_INIT (inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3623 inev.kind = NO_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3624 inev.arg = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3625
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3626 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3627 timestamp = GetEventTime (eventRef) / kEventDurationMillisecond;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3628
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3629 if (!mac_convert_event_ref (eventRef, &er))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3630 goto OTHER;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3631 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3632 timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3633 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3634
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3635 switch (er.what)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3636 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3637 case mouseDown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3638 case mouseUp:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3639 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3640 WindowRef window_ptr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3641 ControlPartCode part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3642 int tool_bar_p = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3643
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3644 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3645 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3646
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3647 /* This is needed to send mouse events like aqua window
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3648 buttons to the correct handler. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3649 read_socket_inev = &inev;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3650 err = SendEventToEventTarget (eventRef, toolbox_dispatcher);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3651 read_socket_inev = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3652 if (err != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3653 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3654 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3655 last_mouse_glyph_frame = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3656
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3657 if (dpyinfo->grabbed && last_mouse_frame
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3658 && FRAME_LIVE_P (last_mouse_frame))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3659 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3660 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3661 part_code = inContent;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3662 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3663 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3664 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3665 part_code = FindWindow (er.where, &window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3666 if (tip_window && window_ptr == tip_window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3667 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3668 HideWindow (tip_window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3669 part_code = FindWindow (er.where, &window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3670 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3671 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3672
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3673 if (er.what != mouseDown
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3674 && (part_code != inContent || dpyinfo->grabbed == 0))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3675 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3676
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3677 switch (part_code)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3678 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3679 case inMenuBar:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3680 f = mac_focus_frame (dpyinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3681 saved_menu_event_location = er.where;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3682 inev.kind = MENU_BAR_ACTIVATE_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3683 XSETFRAME (inev.frame_or_window, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3684 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3685
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3686 case inContent:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3687 if (
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3688 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3689 FrontNonFloatingWindow ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3690 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3691 FrontWindow ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3692 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3693 != window_ptr
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3694 || (mac_window_to_frame (window_ptr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3695 != dpyinfo->x_focus_frame))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3696 SelectWindow (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3697 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3698 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3699 ControlPartCode control_part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3700 ControlRef ch;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3701 Point mouse_loc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3702 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3703 ControlKind control_kind;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3704 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3705
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3706 f = mac_window_to_frame (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3707 /* convert to local coordinates of new window */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3708 mouse_loc.h = (er.where.h
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3709 - (f->left_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3710 + FRAME_OUTER_TO_INNER_DIFF_X (f)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3711 mouse_loc.v = (er.where.v
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3712 - (f->top_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3713 + FRAME_OUTER_TO_INNER_DIFF_Y (f)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3714 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3715 ch = FindControlUnderMouse (mouse_loc, window_ptr,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3716 &control_part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3717 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3718 if (ch)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3719 GetControlKind (ch, &control_kind);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3720 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3721 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3722 control_part_code = FindControl (mouse_loc, window_ptr,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3723 &ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3724 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3725
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3726 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3727 inev.code = mac_get_mouse_btn (eventRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3728 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3729 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3730 inev.code = mac_get_emulated_btn (er.modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3731 inev.modifiers = mac_to_emacs_modifiers (er.modifiers, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3732 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3733 XSETINT (inev.x, mouse_loc.h);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3734 XSETINT (inev.y, mouse_loc.v);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3735
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3736 if ((dpyinfo->grabbed && tracked_scroll_bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3737 || (ch != 0
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3738 #ifndef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3739 /* control_part_code becomes kControlNoPart if
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3740 a progress indicator is clicked. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3741 && control_part_code != kControlNoPart
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3742 #else /* USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3743 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3744 && control_kind.kind == kControlKindScrollBar
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3745 #endif /* MAC_OSX */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3746 #endif /* USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3747 ))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3748 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3749 struct scroll_bar *bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3750
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3751 if (dpyinfo->grabbed && tracked_scroll_bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3752 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3753 bar = tracked_scroll_bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3754 #ifndef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3755 control_part_code = kControlIndicatorPart;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3756 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3757 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3758 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3759 bar = (struct scroll_bar *) GetControlReference (ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3760 #ifdef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3761 /* Make the "Ctrl-Mouse-2 splits window" work
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3762 for toolkit scroll bars. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3763 if (inev.modifiers & ctrl_modifier)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3764 x_scroll_bar_handle_click (bar, control_part_code,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3765 &er, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3766 else if (er.what == mouseDown)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3767 x_scroll_bar_handle_press (bar, control_part_code,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3768 mouse_loc, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3769 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3770 x_scroll_bar_handle_release (bar, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3771 #else /* not USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3772 x_scroll_bar_handle_click (bar, control_part_code,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3773 &er, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3774 if (er.what == mouseDown
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3775 && control_part_code == kControlIndicatorPart)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3776 tracked_scroll_bar = bar;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3777 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3778 tracked_scroll_bar = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3779 #endif /* not USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3780 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3781 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3782 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3783 Lisp_Object window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3784 int x = mouse_loc.h;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3785 int y = mouse_loc.v;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3786
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3787 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3788 if (EQ (window, f->tool_bar_window))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3789 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3790 if (er.what == mouseDown)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3791 handle_tool_bar_click (f, x, y, 1, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3792 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3793 handle_tool_bar_click (f, x, y, 0,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3794 inev.modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3795 tool_bar_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3796 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3797 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3798 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3799 XSETFRAME (inev.frame_or_window, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3800 inev.kind = MOUSE_CLICK_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3801 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3802 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3803
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3804 if (er.what == mouseDown)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3805 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3806 dpyinfo->grabbed |= (1 << inev.code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3807 last_mouse_frame = f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3808
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3809 if (!tool_bar_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3810 last_tool_bar_item = -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3811 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3812 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3813 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3814 if ((dpyinfo->grabbed & (1 << inev.code)) == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3815 /* If a button is released though it was not
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3816 previously pressed, that would be because
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3817 of multi-button emulation. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3818 dpyinfo->grabbed = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3819 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3820 dpyinfo->grabbed &= ~(1 << inev.code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3821 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3822
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3823 /* Ignore any mouse motion that happened before
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3824 this event; any subsequent mouse-movement Emacs
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3825 events should reflect only motion after the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3826 ButtonPress. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3827 if (f != 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3828 f->mouse_moved = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3829
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3830 #ifdef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3831 if (inev.kind == MOUSE_CLICK_EVENT
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3832 || (inev.kind == SCROLL_BAR_CLICK_EVENT
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3833 && (inev.modifiers & ctrl_modifier)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3834 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3835 switch (er.what)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3836 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3837 case mouseDown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3838 inev.modifiers |= down_modifier;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3839 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3840 case mouseUp:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3841 inev.modifiers |= up_modifier;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3842 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3843 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3844 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3845 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3846
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3847 case inDrag:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3848 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3849 case inProxyIcon:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3850 if (IsWindowPathSelectClick (window_ptr, &er))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3851 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3852 WindowPathSelect (window_ptr, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3853 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3854 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3855 if (part_code == inProxyIcon
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3856 && (TrackWindowProxyDrag (window_ptr, er.where)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3857 != errUserWantsToDragWindow))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3858 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3859 DragWindow (window_ptr, er.where, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3860 #else /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3861 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3862 /* Update the frame parameters. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3863 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3864 struct frame *f = mac_window_to_frame (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3865
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3866 if (f && !f->async_iconified)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3867 mac_handle_origin_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3868 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3869 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3870 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3871
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3872 case inGoAway:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3873 if (TrackGoAway (window_ptr, er.where))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3874 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3875 inev.kind = DELETE_WINDOW_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3876 XSETFRAME (inev.frame_or_window,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3877 mac_window_to_frame (window_ptr));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3878 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3879 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3880
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3881 /* window resize handling added --ben */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3882 case inGrow:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3883 do_grow_window (window_ptr, &er);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3884 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3885
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3886 /* window zoom handling added --ben */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3887 case inZoomIn:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3888 case inZoomOut:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3889 if (TrackBox (window_ptr, er.where, part_code))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3890 do_zoom_window (window_ptr, part_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3891 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3892
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3893 #if USE_MAC_TOOLBAR
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3894 case inStructure:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3895 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3896 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3897 HIViewRef ch;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3898
80517
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
3899 if (FrontNonFloatingWindow () != window_ptr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
3900 SelectWindow (window_ptr);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
3901
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3902 err = HIViewGetViewForMouseEvent (HIViewGetRoot (window_ptr),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3903 eventRef, &ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3904 /* This doesn't work on Mac OS X 10.2. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3905 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3906 HIViewClick (ch, eventRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3907 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3908 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3909 #endif /* USE_MAC_TOOLBAR */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3910
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3911 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3912 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3913 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3914 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3915 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3916
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3917 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3918 case updateEvt:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3919 do_window_update ((WindowRef) er.message);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3920 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3921 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3922
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3923 case osEvt:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3924 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3925 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3926 != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3927 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3928 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3929 switch ((er.message >> 24) & 0x000000FF)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3930 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3931 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3932 case suspendResumeMessage:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3933 if (er.message & resumeFlag)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3934 mac_tsm_resume ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3935 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3936 mac_tsm_suspend ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3937 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3938 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3939
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3940 case mouseMovedMessage:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3941 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3942 SetRectRgn (mouse_region, er.where.h, er.where.v,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3943 er.where.h + 1, er.where.v + 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3944 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3945 previous_help_echo_string = help_echo_string;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3946 help_echo_string = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3947
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3948 if (dpyinfo->grabbed && last_mouse_frame
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3949 && FRAME_LIVE_P (last_mouse_frame))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3950 f = last_mouse_frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3951 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3952 f = dpyinfo->x_focus_frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3953
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3954 if (dpyinfo->mouse_face_hidden)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3955 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3956 dpyinfo->mouse_face_hidden = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3957 clear_mouse_face (dpyinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3958 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3959
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3960 if (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3961 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3962 WindowRef wp = FRAME_MAC_WINDOW (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3963 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3964
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3965 mouse_pos.h = (er.where.h
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3966 - (f->left_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3967 + FRAME_OUTER_TO_INNER_DIFF_X (f)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3968 mouse_pos.v = (er.where.v
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3969 - (f->top_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3970 + FRAME_OUTER_TO_INNER_DIFF_Y (f)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3971 if (dpyinfo->grabbed && tracked_scroll_bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3972 #ifdef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3973 x_scroll_bar_handle_drag (wp, tracked_scroll_bar,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3974 mouse_pos, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3975 #else /* not USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3976 x_scroll_bar_note_movement (tracked_scroll_bar,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3977 mouse_pos.v
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3978 - XINT (tracked_scroll_bar->top),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3979 er.when * (1000 / 60));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3980 #endif /* not USE_TOOLKIT_SCROLL_BARS */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3981 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3982 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3983 /* Generate SELECT_WINDOW_EVENTs when needed. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3984 if (!NILP (Vmouse_autoselect_window))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3985 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3986 Lisp_Object window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3987
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3988 window = window_from_coordinates (f,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3989 mouse_pos.h,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3990 mouse_pos.v,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3991 0, 0, 0, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3992
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3993 /* Window will be selected only when it is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3994 not selected now and last mouse movement
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3995 event was not in it. Minibuffer window
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3996 will be selected only when it is active. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3997 if (WINDOWP (window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3998 && !EQ (window, last_window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3999 && !EQ (window, selected_window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4000 /* For click-to-focus window managers
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4001 create event iff we don't leave the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4002 selected frame. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4003 && (focus_follows_mouse
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4004 || (EQ (XWINDOW (window)->frame,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4005 XWINDOW (selected_window)->frame))))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4006 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4007 inev.kind = SELECT_WINDOW_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4008 inev.frame_or_window = window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4009 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4010
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4011 last_window=window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4012 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4013 if (!note_mouse_movement (f, &mouse_pos))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4014 help_echo_string = previous_help_echo_string;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4015 #if USE_MAC_TOOLBAR
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4016 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4017 mac_tool_bar_note_mouse_movement (f, eventRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4018 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4019 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4020 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4021
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4022 /* If the contents of the global variable
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4023 help_echo_string has changed, generate a
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4024 HELP_EVENT. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4025 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4026 do_help = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4027 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4028 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4029 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4030
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4031 case activateEvt:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4032 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4033 WindowRef window_ptr = (WindowRef) er.message;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4034 OSErr err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4035 ControlRef root_control;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4036
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4037 if (window_ptr == tip_window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4038 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4039 HideWindow (tip_window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4040 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4041 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4042
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4043 if (!is_emacs_window (window_ptr))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4044 goto OTHER;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4045
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4046 f = mac_window_to_frame (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4047
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4048 if ((er.modifiers & activeFlag) != 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4049 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4050 /* A window has been activated */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4051 Point mouse_loc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4052
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4053 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4054 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4055 ActivateControl (root_control);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4056
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4057 x_detect_focus_change (dpyinfo, &er, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4058
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4059 mouse_loc.h = (er.where.h
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4060 - (f->left_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4061 + FRAME_OUTER_TO_INNER_DIFF_X (f)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4062 mouse_loc.v = (er.where.v
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4063 - (f->top_pos
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4064 + FRAME_OUTER_TO_INNER_DIFF_Y (f)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4065 /* Window-activated event counts as mouse movement,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4066 so update things that depend on mouse position. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4067 note_mouse_movement (f, &mouse_loc);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4068 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4069 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4070 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4071 /* A window has been deactivated */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4072 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4073 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4074 DeactivateControl (root_control);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4075
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4076 #ifdef USE_TOOLKIT_SCROLL_BARS
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4077 if (dpyinfo->grabbed && tracked_scroll_bar)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4078 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4079 struct input_event event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4080
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4081 EVENT_INIT (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4082 event.kind = NO_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4083 x_scroll_bar_handle_release (tracked_scroll_bar, &event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4084 if (event.kind != NO_EVENT)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4085 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4086 event.timestamp = timestamp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4087 kbd_buffer_store_event_hold (&event, hold_quit);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4088 count++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4089 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4090 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4091 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4092 dpyinfo->grabbed = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4093
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4094 x_detect_focus_change (dpyinfo, &er, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4095
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4096 if (f == dpyinfo->mouse_face_mouse_frame)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4097 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4098 /* If we move outside the frame, then we're
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4099 certainly no longer on any text in the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4100 frame. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4101 clear_mouse_face (dpyinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4102 dpyinfo->mouse_face_mouse_frame = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4103 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4104
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4105 /* Generate a nil HELP_EVENT to cancel a help-echo.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4106 Do it only if there's something to cancel.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4107 Otherwise, the startup message is cleared when the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4108 mouse leaves the frame. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4109 if (any_help_event_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4110 do_help = -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4111 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4112 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4113 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4114
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4115 case keyDown:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4116 case keyUp:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4117 case autoKey:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4118 ObscureCursor ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4119
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4120 f = mac_focus_frame (dpyinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4121 XSETFRAME (inev.frame_or_window, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4122
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4123 /* If mouse-highlight is an integer, input clears out mouse
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4124 highlighting. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4125 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4126 && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4127 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4128 clear_mouse_face (dpyinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4129 dpyinfo->mouse_face_hidden = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4130 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4131
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4132 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4133 UInt32 modifiers = er.modifiers, mapped_modifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4134 UInt32 key_code = (er.message & keyCodeMask) >> 8;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4135
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4136 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4137 GetEventParameter (eventRef, kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4138 typeUInt32, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4139 sizeof (UInt32), NULL, &modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4140 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4141 mapped_modifiers = mac_mapped_modifiers (modifiers, key_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4142
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4143 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4144 if (!(mapped_modifiers
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4145 & ~(mac_pass_command_to_system ? cmdKey : 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4146 & ~(mac_pass_control_to_system ? controlKey : 0)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4147 goto OTHER;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4148 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4149 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4150 if (er.what != keyUp)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4151 do_keystroke (er.what, er.message & charCodeMask,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4152 key_code, modifiers, timestamp, &inev);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4153 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4154 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4155
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4156 case kHighLevelEvent:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4157 AEProcessAppleEvent (&er);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4158 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4159
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4160 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4161 OTHER:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4162 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4163 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4164 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4165
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4166 read_socket_inev = &inev;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4167 err = SendEventToEventTarget (eventRef, toolbox_dispatcher);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4168 read_socket_inev = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4169 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4170 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4171 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4172 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4173 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4174 ReleaseEvent (eventRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4175 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4176
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4177 if (inev.kind != NO_EVENT)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4178 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4179 inev.timestamp = timestamp;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4180 kbd_buffer_store_event_hold (&inev, hold_quit);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4181 count++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4182 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4183
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4184 if (do_help
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4185 && !(hold_quit && hold_quit->kind != NO_EVENT))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4186 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4187 Lisp_Object frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4188
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4189 if (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4190 XSETFRAME (frame, f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4191 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4192 frame = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4193
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4194 if (do_help > 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4195 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4196 any_help_event_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4197 gen_help_event (help_echo_string, frame, help_echo_window,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4198 help_echo_object, help_echo_pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4199 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4200 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4201 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4202 help_echo_string = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4203 gen_help_event (Qnil, frame, Qnil, Qnil, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4204 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4205 count++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4206 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4207 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4208
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4209 /* If the focus was just given to an autoraising frame,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4210 raise it now. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4211 /* ??? This ought to be able to handle more than one such frame. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4212 if (pending_autoraise_frame)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4213 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4214 x_raise_frame (pending_autoraise_frame);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4215 pending_autoraise_frame = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4216 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4217
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4218 if (mac_screen_config_changed)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4219 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4220 mac_get_screen_info (dpyinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4221 mac_screen_config_changed = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4222 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4223
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4224 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4225 /* Check which frames are still visible. We do this here because
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4226 there doesn't seem to be any direct notification from the Window
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4227 Manager that the visibility of a window has changed (at least,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4228 not in all cases). */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4229 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4230 Lisp_Object tail, frame;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4231
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4232 FOR_EACH_FRAME (tail, frame)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4233 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4234 struct frame *f = XFRAME (frame);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4235
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4236 /* The tooltip has been drawn already. Avoid the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4237 SET_FRAME_GARBAGED in mac_handle_visibility_change. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4238 if (EQ (frame, tip_frame))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4239 continue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4240
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4241 if (FRAME_MAC_P (f))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4242 mac_handle_visibility_change (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4243 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4244 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4245 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4246
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4247 --handling_signal;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4248 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4249 return count;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4250 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4251
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4252
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4253 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4254 Busy cursor
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4255 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4256
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4257 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4258 /* Show the spinning progress indicator for the frame F. Create it if
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4259 it doesn't exist yet. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4260
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4261 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4262 mac_show_hourglass (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4263 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4264 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4265 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4266 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4267 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4268 if (!f->output_data.mac->hourglass_control)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4269 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4270 Window w = FRAME_MAC_WINDOW (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4271 Rect r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4272 ControlRef c;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4273
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4274 GetWindowPortBounds (w, &r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4275 r.left = r.right - HOURGLASS_WIDTH;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4276 r.bottom = r.top + HOURGLASS_HEIGHT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4277 if (CreateChasingArrowsControl (w, &r, &c) == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4278 f->output_data.mac->hourglass_control = c;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4279 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4280
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4281 if (f->output_data.mac->hourglass_control)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4282 ShowControl (f->output_data.mac->hourglass_control);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4283 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4284
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4285 /* Hide the spinning progress indicator for the frame F. Do nothing
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4286 it doesn't exist yet. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4287
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4288 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4289 mac_hide_hourglass (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4290 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4291 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4292 if (f->output_data.mac->hourglass_control)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4293 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4294 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4295 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4296 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4297 HideControl (f->output_data.mac->hourglass_control);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4298 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4299 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4300
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4301 /* Reposition the spinning progress indicator for the frame F. Do
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4302 nothing it doesn't exist yet. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4303
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4304 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4305 mac_reposition_hourglass (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4306 struct frame *f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4307 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4308 if (f->output_data.mac->hourglass_control)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4309 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4310 #if USE_CG_DRAWING
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4311 mac_prepare_for_quickdraw (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4312 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4313 MoveControl (f->output_data.mac->hourglass_control,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4314 FRAME_PIXEL_WIDTH (f) - HOURGLASS_WIDTH, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4315 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4316 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4317 #endif /* TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4318
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4319
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4320 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4321 File selection dialog
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4322 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4323
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4324 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4325 extern Lisp_Object Qfile_name_history;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4326
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4327 static pascal void mac_nav_event_callback P_ ((NavEventCallbackMessage,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4328 NavCBRecPtr, void *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4329
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4330 /* The actual implementation of Fx_file_dialog. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4331
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4332 Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4333 mac_file_dialog (prompt, dir, default_filename, mustmatch, only_dir_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4334 Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4335 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4336 Lisp_Object file = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4337 int count = SPECPDL_INDEX ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4338 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4339 char filename[MAXPATHLEN];
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4340 static NavEventUPP mac_nav_event_callbackUPP = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4341
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4342 check_mac ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4343
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4344 GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4345 CHECK_STRING (prompt);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4346 CHECK_STRING (dir);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4347
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4348 /* Create the dialog with PROMPT as title, using DIR as initial
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4349 directory and using "*" as pattern. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4350 dir = Fexpand_file_name (dir, Qnil);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4351
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4352 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4353 OSStatus status;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4354 NavDialogCreationOptions options;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4355 NavDialogRef dialogRef;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4356 NavTypeListHandle fileTypes = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4357 NavUserAction userAction;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4358 CFStringRef message=NULL, saveName = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4359
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4360 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4361 /* No need for a callback function because we are modal */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4362 NavGetDefaultDialogCreationOptions(&options);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4363 options.modality = kWindowModalityAppModal;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4364 options.location.h = options.location.v = -1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4365 options.optionFlags = kNavDefaultNavDlogOptions;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4366 options.optionFlags |= kNavAllFilesInPopup; /* All files allowed */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4367 options.optionFlags |= kNavSelectAllReadableItem;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4368 options.optionFlags &= ~kNavAllowMultipleFiles;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4369 if (!NILP(prompt))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4370 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4371 message = cfstring_create_with_string (prompt);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4372 options.message = message;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4373 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4374 /* Don't set the application, let it use default.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4375 options.clientName = CFSTR ("Emacs");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4376 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4377
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4378 if (mac_nav_event_callbackUPP == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4379 mac_nav_event_callbackUPP = NewNavEventUPP (mac_nav_event_callback);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4380
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4381 if (!NILP (only_dir_p))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4382 status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4383 NULL, NULL, &dialogRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4384 else if (NILP (mustmatch))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4385 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4386 /* This is a save dialog */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4387 options.optionFlags |= kNavDontConfirmReplacement;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4388 options.actionButtonLabel = CFSTR ("Ok");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4389 options.windowTitle = CFSTR ("Enter name");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4390
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4391 if (STRINGP (default_filename))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4392 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4393 Lisp_Object utf8 = ENCODE_UTF_8 (default_filename);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4394 char *begPtr = SDATA(utf8);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4395 char *filePtr = begPtr + SBYTES(utf8);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4396 while (filePtr != begPtr && !IS_DIRECTORY_SEP(filePtr[-1]))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4397 filePtr--;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4398 saveName = cfstring_create_with_utf8_cstring (filePtr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4399 options.saveFileName = saveName;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4400 options.optionFlags |= kNavSelectDefaultLocation;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4401 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4402 status = NavCreatePutFileDialog(&options,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4403 'TEXT', kNavGenericSignature,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4404 mac_nav_event_callbackUPP, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4405 &dialogRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4406 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4407 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4408 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4409 /* This is an open dialog*/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4410 status = NavCreateChooseFileDialog(&options, fileTypes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4411 mac_nav_event_callbackUPP, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4412 NULL, NULL, &dialogRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4413 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4414
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4415 /* Set the default location and continue*/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4416 if (status == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4417 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4418 Lisp_Object encoded_dir = ENCODE_FILE (dir);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4419 AEDesc defLocAed;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4420
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4421 status = AECreateDesc (TYPE_FILE_NAME, SDATA (encoded_dir),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4422 SBYTES (encoded_dir), &defLocAed);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4423 if (status == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4424 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4425 NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4426 AEDisposeDesc(&defLocAed);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4427 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4428 status = NavDialogRun(dialogRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4429 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4430
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4431 if (saveName) CFRelease(saveName);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4432 if (message) CFRelease(message);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4433
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4434 if (status == noErr) {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4435 userAction = NavDialogGetUserAction(dialogRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4436 switch (userAction)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4437 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4438 case kNavUserActionNone:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4439 case kNavUserActionCancel:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4440 break; /* Treat cancel like C-g */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4441 case kNavUserActionOpen:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4442 case kNavUserActionChoose:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4443 case kNavUserActionSaveAs:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4444 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4445 NavReplyRecord reply;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4446 Size len;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4447
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4448 status = NavDialogGetReply(dialogRef, &reply);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4449 if (status != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4450 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4451 status = AEGetNthPtr (&reply.selection, 1, TYPE_FILE_NAME,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4452 NULL, NULL, filename,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4453 sizeof (filename) - 1, &len);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4454 if (status == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4455 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4456 len = min (len, sizeof (filename) - 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4457 filename[len] = '\0';
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4458 if (reply.saveFileName)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4459 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4460 /* If it was a saved file, we need to add the file name */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4461 if (len && len < sizeof (filename) - 1
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4462 && filename[len-1] != '/')
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4463 filename[len++] = '/';
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4464 CFStringGetCString(reply.saveFileName, filename+len,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4465 sizeof (filename) - len,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4466 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4467 kCFStringEncodingUTF8
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4468 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4469 CFStringGetSystemEncoding ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4470 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4471 );
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4472 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4473 file = DECODE_FILE (make_unibyte_string (filename,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4474 strlen (filename)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4475 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4476 NavDisposeReply(&reply);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4477 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4478 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4479 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4480 NavDialogDispose(dialogRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4481 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4482 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4483 else {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4484 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4485 /* Fall back on minibuffer if there was a problem */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4486 file = Fcompleting_read (prompt, intern ("read-file-name-internal"),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4487 dir, mustmatch, dir, Qfile_name_history,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4488 default_filename, Qnil);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4489 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4490 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4491
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4492 UNGCPRO;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4493
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4494 /* Make "Cancel" equivalent to C-g. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4495 if (NILP (file))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4496 Fsignal (Qquit, Qnil);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4497
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4498 return unbind_to (count, file);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4499 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4500
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4501 /* Need to register some event callback function for enabling drag and
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4502 drop in Navigation Service dialogs. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4503 static pascal void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4504 mac_nav_event_callback (selector, parms, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4505 NavEventCallbackMessage selector;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4506 NavCBRecPtr parms;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4507 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4508 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4509 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4510 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4511
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4512
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4513 /************************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4514 Menu
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4515 ************************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4516
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4517 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4518 #include <MacTypes.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4519 #include <Menus.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4520 #include <Quickdraw.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4521 #include <ToolUtils.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4522 #include <Fonts.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4523 #include <Controls.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4524 #include <Windows.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4525 #include <Events.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4526 #if defined (__MRC__) || (__MSL__ >= 0x6000)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4527 #include <ControlDefinitions.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4528 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4529 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4530
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4531 extern int menu_item_selection;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4532 extern int popup_activated_flag;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4533 extern int name_is_separator P_ ((const char *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4534 extern void find_and_call_menu_selection P_ ((FRAME_PTR, int, Lisp_Object,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4535 void *));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4536 extern void set_frame_menubar P_ ((FRAME_PTR, int, int));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4537
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4538 enum mac_menu_kind { /* Menu ID range */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4539 MAC_MENU_APPLE, /* 0 (Reserved by Apple) */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4540 MAC_MENU_MENU_BAR, /* 1 .. 233 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4541 MAC_MENU_M_APPLE, /* 234 (== M_APPLE) */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4542 MAC_MENU_POPUP, /* 235 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4543 MAC_MENU_DRIVER, /* 236 .. 255 (Reserved) */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4544 MAC_MENU_MENU_BAR_SUB, /* 256 .. 16383 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4545 MAC_MENU_POPUP_SUB, /* 16384 .. 32767 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4546 MAC_MENU_END /* 32768 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4547 };
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4548
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4549 static const int min_menu_id[] = {0, 1, 234, 235, 236, 256, 16384, 32768};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4550
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4551 static int fill_menu P_ ((MenuRef, widget_value *, enum mac_menu_kind, int));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4552 static void dispose_menus P_ ((enum mac_menu_kind, int));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4553
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4554 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4555 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4556 do_apple_menu (SInt16 menu_item)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4557 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4558 Str255 item_name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4559 SInt16 da_driver_refnum;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4560
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4561 if (menu_item == I_ABOUT)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4562 NoteAlert (ABOUT_ALERT_ID, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4563 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4564 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4565 GetMenuItemText (GetMenuRef (M_APPLE), menu_item, item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4566 da_driver_refnum = OpenDeskAcc (item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4567 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4568 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4569 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4570
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4571 /* Activate the menu bar of frame F.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4572 This is called from keyboard.c when it gets the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4573 MENU_BAR_ACTIVATE_EVENT out of the Emacs event queue.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4574
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4575 To activate the menu bar, we use the button-press event location
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4576 that was saved in saved_menu_event_location.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4577
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4578 But first we recompute the menu bar contents (the whole tree).
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4579
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4580 The reason for saving the button event until here, instead of
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4581 passing it to the toolkit right away, is that we can safely
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4582 execute Lisp code. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4583
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4584 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4585 x_activate_menubar (f)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4586 FRAME_PTR f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4587 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4588 SInt32 menu_choice;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4589 SInt16 menu_id, menu_item;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4590
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4591 set_frame_menubar (f, 0, 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4592 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4593
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4594 popup_activated_flag = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4595 menu_choice = MenuSelect (saved_menu_event_location);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4596 popup_activated_flag = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4597 menu_id = HiWord (menu_choice);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4598 menu_item = LoWord (menu_choice);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4599
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4600 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4601 if (menu_id == min_menu_id[MAC_MENU_M_APPLE])
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4602 do_apple_menu (menu_item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4603 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4604 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4605 if (menu_id)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4606 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4607 MenuRef menu = GetMenuRef (menu_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4608
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4609 if (menu)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4610 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4611 UInt32 refcon;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4612
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4613 GetMenuItemRefCon (menu, menu_item, &refcon);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4614 find_and_call_menu_selection (f, f->menu_bar_items_used,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4615 f->menu_bar_vector, (void *) refcon);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4616 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4617 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4618
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4619 HiliteMenu (0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4620
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4621 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4622 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4623
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4624 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4625 extern Lisp_Object Vshow_help_function;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4626
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4627 static Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4628 restore_show_help_function (old_show_help_function)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4629 Lisp_Object old_show_help_function;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4630 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4631 Vshow_help_function = old_show_help_function;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4632
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4633 return Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4634 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4635
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4636 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4637 menu_target_item_handler (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4638 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4639 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4640 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4641 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4642 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4643 MenuRef menu;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4644 MenuItemIndex menu_item;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4645 Lisp_Object help;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4646 GrafPtr port;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4647 int specpdl_count = SPECPDL_INDEX ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4648
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4649 /* Don't be bothered with the overflowed toolbar items menu. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4650 if (!popup_activated ())
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4651 return eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4652
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4653 err = GetEventParameter (event, kEventParamDirectObject, typeMenuRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4654 NULL, sizeof (MenuRef), NULL, &menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4655 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4656 err = GetEventParameter (event, kEventParamMenuItemIndex,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4657 typeMenuItemIndex, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4658 sizeof (MenuItemIndex), NULL, &menu_item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4659 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4660 err = GetMenuItemProperty (menu, menu_item,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4661 MAC_EMACS_CREATOR_CODE, 'help',
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4662 sizeof (Lisp_Object), NULL, &help);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4663 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4664 help = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4665
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4666 /* Temporarily bind Vshow_help_function to Qnil because we don't
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4667 want tooltips during menu tracking. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4668 record_unwind_protect (restore_show_help_function, Vshow_help_function);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4669 Vshow_help_function = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4670 GetPort (&port);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4671 show_help_echo (help, Qnil, Qnil, Qnil, 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4672 SetPort (port);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4673 unbind_to (specpdl_count, Qnil);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4674
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4675 return err == noErr ? noErr : eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4676 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4677
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4678 /* Showing help echo string during menu tracking. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4679
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4680 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4681 install_menu_target_item_handler ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4682 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4683 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4684 {{kEventClassMenu, kEventMenuTargetItem}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4685
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4686 return InstallApplicationEventHandler (NewEventHandlerUPP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4687 (menu_target_item_handler),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4688 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4689 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4690 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4691 #endif /* TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4692
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4693 /* Event handler function that pops down a menu on C-g. We can only pop
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4694 down menus if CancelMenuTracking is present (OSX 10.3 or later). */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4695
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4696 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4697 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4698 menu_quit_handler (nextHandler, theEvent, userData)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4699 EventHandlerCallRef nextHandler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4700 EventRef theEvent;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4701 void* userData;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4702 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4703 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4704 UInt32 keyCode;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4705 UInt32 keyModifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4706
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4707 err = GetEventParameter (theEvent, kEventParamKeyCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4708 typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4709
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4710 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4711 err = GetEventParameter (theEvent, kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4712 typeUInt32, NULL, sizeof(UInt32),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4713 NULL, &keyModifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4714
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4715 if (err == noErr && mac_quit_char_key_p (keyModifiers, keyCode))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4716 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4717 MenuRef menu = userData != 0
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4718 ? (MenuRef)userData : AcquireRootMenu ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4719
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4720 CancelMenuTracking (menu, true, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4721 if (!userData) ReleaseMenu (menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4722 return noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4723 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4724
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4725 return CallNextEventHandler (nextHandler, theEvent);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4726 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4727 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4728
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4729 /* Add event handler to all menus that belong to KIND so we can detect
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4730 C-g. ROOT_MENU is the root menu of the tracking session to dismiss
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4731 when C-g is detected. NULL means the menu bar. If
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4732 CancelMenuTracking isn't available, do nothing. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4733
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4734 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4735 install_menu_quit_handler (kind, root_menu)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4736 enum mac_menu_kind kind;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4737 MenuRef root_menu;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4738 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4739 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4740 static const EventTypeSpec typesList[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4741 {{kEventClassKeyboard, kEventRawKeyDown}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4742 int id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4743
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4744 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4745 if (CancelMenuTracking == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4746 return;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4747 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4748 for (id = min_menu_id[kind]; id < min_menu_id[kind + 1]; id++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4749 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4750 MenuRef menu = GetMenuRef (id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4751
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4752 if (menu == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4753 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4754 InstallMenuEventHandler (menu, menu_quit_handler,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4755 GetEventTypeCount (typesList),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4756 typesList, root_menu, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4757 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4758 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4759 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4760
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4761 static Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4762 pop_down_menu (arg)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4763 Lisp_Object arg;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4764 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4765 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4766 FRAME_PTR f = p->pointer;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4767 MenuRef menu = GetMenuRef (min_menu_id[MAC_MENU_POPUP]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4768
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4769 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4770
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4771 /* Must reset this manually because the button release event is not
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4772 passed to Emacs event loop. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4773 FRAME_MAC_DISPLAY_INFO (f)->grabbed = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4774
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4775 /* delete all menus */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4776 dispose_menus (MAC_MENU_POPUP_SUB, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4777 DeleteMenu (min_menu_id[MAC_MENU_POPUP]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4778 DisposeMenu (menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4779
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4780 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4781
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4782 return Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4783 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4784
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4785 /* Pop up the menu for frame F defined by FIRST_WV at X/Y and loop
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4786 until the menu pops down. Return the selection. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4787
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4788 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4789 create_and_show_popup_menu (f, first_wv, x, y, for_click)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4790 FRAME_PTR f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4791 widget_value *first_wv;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4792 int x;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4793 int y;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4794 int for_click;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4795 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4796 int result = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4797 MenuRef menu = NewMenu (min_menu_id[MAC_MENU_POPUP], "\p");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4798 int menu_item_choice;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4799 int specpdl_count = SPECPDL_INDEX ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4800
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4801 InsertMenu (menu, -1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4802 fill_menu (menu, first_wv->contents, MAC_MENU_POPUP_SUB,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4803 min_menu_id[MAC_MENU_POPUP_SUB]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4804
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4805 /* Add event handler so we can detect C-g. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4806 install_menu_quit_handler (MAC_MENU_POPUP, menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4807 install_menu_quit_handler (MAC_MENU_POPUP_SUB, menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4808
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4809 record_unwind_protect (pop_down_menu, make_save_value (f, 0));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4810
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4811 /* Adjust coordinates to be root-window-relative. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4812 x += f->left_pos + FRAME_OUTER_TO_INNER_DIFF_X (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4813 y += f->top_pos + FRAME_OUTER_TO_INNER_DIFF_Y (f);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4814
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4815 /* Display the menu. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4816 popup_activated_flag = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4817 menu_item_choice = PopUpMenuSelect (menu, y, x, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4818 popup_activated_flag = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4819
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4820 /* Get the refcon to find the correct item */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4821 if (menu_item_choice)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4822 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4823 MenuRef sel_menu = GetMenuRef (HiWord (menu_item_choice));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4824
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4825 if (sel_menu)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4826 GetMenuItemRefCon (sel_menu, LoWord (menu_item_choice),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4827 (UInt32 *) &result);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4828 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4829
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4830 unbind_to (specpdl_count, Qnil);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4831
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4832 menu_item_selection = result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4833 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4834
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4835 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4836 add_menu_item (menu, pos, wv)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4837 MenuRef menu;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4838 int pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4839 widget_value *wv;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4840 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4841 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4842 CFStringRef item_name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4843 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4844 Str255 item_name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4845 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4846
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4847 if (name_is_separator (wv->name))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4848 AppendMenu (menu, "\p-");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4849 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4850 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4851 AppendMenu (menu, "\pX");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4852
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4853 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4854 item_name = cfstring_create_with_utf8_cstring (wv->name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4855
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4856 if (wv->key != NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4857 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4858 CFStringRef name, key;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4859
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4860 name = item_name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4861 key = cfstring_create_with_utf8_cstring (wv->key);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4862 item_name = CFStringCreateWithFormat (NULL, NULL, CFSTR ("%@ %@"),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4863 name, key);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4864 CFRelease (name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4865 CFRelease (key);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4866 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4867
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4868 SetMenuItemTextWithCFString (menu, pos, item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4869 CFRelease (item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4870
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4871 if (wv->enabled)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4872 EnableMenuItem (menu, pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4873 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4874 DisableMenuItem (menu, pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4875
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4876 if (STRINGP (wv->help))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4877 SetMenuItemProperty (menu, pos, MAC_EMACS_CREATOR_CODE, 'help',
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4878 sizeof (Lisp_Object), &wv->help);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4879 #else /* ! TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4880 item_name[sizeof (item_name) - 1] = '\0';
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4881 strncpy (item_name, wv->name, sizeof (item_name) - 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4882 if (wv->key != NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4883 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4884 int len = strlen (item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4885
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4886 strncpy (item_name + len, " ", sizeof (item_name) - 1 - len);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4887 len = strlen (item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4888 strncpy (item_name + len, wv->key, sizeof (item_name) - 1 - len);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4889 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4890 c2pstr (item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4891 SetMenuItemText (menu, pos, item_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4892
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4893 if (wv->enabled)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4894 EnableItem (menu, pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4895 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4896 DisableItem (menu, pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4897 #endif /* ! TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4898
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4899 /* Draw radio buttons and tickboxes. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4900 if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4901 || wv->button_type == BUTTON_TYPE_RADIO))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4902 SetItemMark (menu, pos, checkMark);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4903 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4904 SetItemMark (menu, pos, noMark);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4905
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4906 SetMenuItemRefCon (menu, pos, (UInt32) wv->call_data);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4907 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4908 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4909
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4910 /* Construct native Mac OS menu based on widget_value tree. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4911
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4912 static int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4913 fill_menu (menu, wv, kind, submenu_id)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4914 MenuRef menu;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4915 widget_value *wv;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4916 enum mac_menu_kind kind;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4917 int submenu_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4918 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4919 int pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4920
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4921 for (pos = 1; wv != NULL; wv = wv->next, pos++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4922 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4923 add_menu_item (menu, pos, wv);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4924 if (wv->contents && submenu_id < min_menu_id[kind + 1])
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4925 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4926 MenuRef submenu = NewMenu (submenu_id, "\pX");
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4927
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4928 InsertMenu (submenu, -1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4929 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4930 SetMenuItemHierarchicalMenu (menu, pos, submenu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4931 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4932 SetMenuItemHierarchicalID (menu, pos, submenu_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4933 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4934 submenu_id = fill_menu (submenu, wv->contents, kind, submenu_id + 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4935 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4936 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4937
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4938 return submenu_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4939 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4940
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4941 /* Fill menu bar with the items defined by WV. If DEEP_P, consider
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4942 the entire menu trees we supply, rather than just the menu bar item
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4943 names. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4944
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4945 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4946 mac_fill_menubar (wv, deep_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4947 widget_value *wv;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4948 int deep_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4949 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4950 int id, submenu_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4951 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4952 int title_changed_p = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4953 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4954
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4955 /* Clean up the menu bar when filled by the entire menu trees. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4956 if (deep_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4957 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4958 dispose_menus (MAC_MENU_MENU_BAR, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4959 dispose_menus (MAC_MENU_MENU_BAR_SUB, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4960 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4961 title_changed_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4962 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4963 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4964
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4965 /* Fill menu bar titles and submenus. Reuse the existing menu bar
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4966 titles as much as possible to minimize redraw (if !deep_p). */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4967 submenu_id = min_menu_id[MAC_MENU_MENU_BAR_SUB];
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4968 for (id = min_menu_id[MAC_MENU_MENU_BAR];
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4969 wv != NULL && id < min_menu_id[MAC_MENU_MENU_BAR + 1];
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4970 wv = wv->next, id++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4971 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4972 OSStatus err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4973 MenuRef menu;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4974 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4975 CFStringRef title;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4976
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4977 title = CFStringCreateWithCString (NULL, wv->name,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4978 kCFStringEncodingMacRoman);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4979 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4980 Str255 title;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4981
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4982 strncpy (title, wv->name, 255);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4983 title[255] = '\0';
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4984 c2pstr (title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4985 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4986
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4987 menu = GetMenuRef (id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4988 if (menu)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4989 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4990 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4991 CFStringRef old_title;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4992
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4993 err = CopyMenuTitleAsCFString (menu, &old_title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4994 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4995 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4996 if (CFStringCompare (title, old_title, 0) != kCFCompareEqualTo)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4997 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4998 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4999 if (id + 1 == min_menu_id[MAC_MENU_MENU_BAR + 1]
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5000 || GetMenuRef (id + 1) == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5001 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5002 /* This is a workaround for Mac OS X 10.5 where
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5003 just calling SetMenuTitleWithCFString fails
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5004 to change the title of the last (Help) menu
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5005 in the menu bar. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5006 DeleteMenu (id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5007 DisposeMenu (menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5008 menu = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5009 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5010 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5011 #endif /* MAC_OSX */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5012 err = SetMenuTitleWithCFString (menu, title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5013 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5014 CFRelease (old_title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5015 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5016 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5017 err = SetMenuTitleWithCFString (menu, title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5018 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5019 if (!EqualString (title, (*menu)->menuData, false, false))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5020 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5021 DeleteMenu (id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5022 DisposeMenu (menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5023 menu = NewMenu (id, title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5024 InsertMenu (menu, GetMenuRef (id + 1) ? id + 1 : 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5025 title_changed_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5026 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5027 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5028 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5029
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5030 if (!menu)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5031 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5032 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5033 err = CreateNewMenu (id, 0, &menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5034 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5035 err = SetMenuTitleWithCFString (menu, title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5036 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5037 menu = NewMenu (id, title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5038 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5039 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5040 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5041 InsertMenu (menu, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5042 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5043 title_changed_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5044 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5045 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5046 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5047 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5048 CFRelease (title);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5049 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5050
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5051 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5052 if (wv->contents)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5053 submenu_id = fill_menu (menu, wv->contents, MAC_MENU_MENU_BAR_SUB,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5054 submenu_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5055 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5056
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5057 if (id < min_menu_id[MAC_MENU_MENU_BAR + 1] && GetMenuRef (id))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5058 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5059 dispose_menus (MAC_MENU_MENU_BAR, id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5060 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5061 title_changed_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5062 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5063 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5064
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5065 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5066 if (title_changed_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5067 InvalMenuBar ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5068 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5069
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5070 /* Add event handler so we can detect C-g. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5071 install_menu_quit_handler (MAC_MENU_MENU_BAR, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5072 install_menu_quit_handler (MAC_MENU_MENU_BAR_SUB, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5073 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5074
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5075 /* Dispose of menus that belong to KIND, and remove them from the menu
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5076 list. ID is the lower bound of menu IDs that will be processed. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5077
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5078 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5079 dispose_menus (kind, id)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5080 enum mac_menu_kind kind;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5081 int id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5082 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5083 for (id = max (id, min_menu_id[kind]); id < min_menu_id[kind + 1]; id++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5084 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5085 MenuRef menu = GetMenuRef (id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5086
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5087 if (menu == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5088 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5089 DeleteMenu (id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5090 DisposeMenu (menu);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5091 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5092 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5093
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5094 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5095 init_menu_bar ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5096 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5097 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5098 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5099 MenuRef menu;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5100 MenuItemIndex menu_index;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5101
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5102 err = GetIndMenuItemWithCommandID (NULL, kHICommandQuit, 1,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5103 &menu, &menu_index);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5104 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5105 SetMenuItemCommandKey (menu, menu_index, false, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5106 EnableMenuCommand (NULL, kHICommandPreferences);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5107 err = GetIndMenuItemWithCommandID (NULL, kHICommandPreferences, 1,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5108 &menu, &menu_index);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5109 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5110 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5111 SetMenuItemCommandKey (menu, menu_index, false, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5112 InsertMenuItemTextWithCFString (menu, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5113 0, kMenuItemAttrSeparator, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5114 InsertMenuItemTextWithCFString (menu, CFSTR ("About Emacs"),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5115 0, 0, kHICommandAbout);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5116 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5117 #else /* !MAC_OSX */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5118 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5119 SetMenuItemCommandID (GetMenuRef (M_APPLE), I_ABOUT, kHICommandAbout);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5120 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5121 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5122 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5123
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5124
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5125 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5126 Popup Dialog
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5127 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5128
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5129 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5130 #define DIALOG_BUTTON_COMMAND_ID_OFFSET 'Bt\0\0'
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5131 #define DIALOG_BUTTON_COMMAND_ID_P(id) \
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5132 (((id) & ~0xffff) == DIALOG_BUTTON_COMMAND_ID_OFFSET)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5133 #define DIALOG_BUTTON_COMMAND_ID_VALUE(id) \
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5134 ((id) - DIALOG_BUTTON_COMMAND_ID_OFFSET)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5135 #define DIALOG_BUTTON_MAKE_COMMAND_ID(value) \
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5136 ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5137
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5138 extern EMACS_TIME timer_check P_ ((int));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5139 static int quit_dialog_event_loop;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5140
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5141 static pascal OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5142 mac_handle_dialog_event (next_handler, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5143 EventHandlerCallRef next_handler;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5144 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5145 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5146 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5147 OSStatus err, result = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5148 WindowRef window = (WindowRef) data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5149
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5150 switch (GetEventClass (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5151 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5152 case kEventClassCommand:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5153 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5154 HICommand command;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5155
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5156 err = GetEventParameter (event, kEventParamDirectObject,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5157 typeHICommand, NULL, sizeof (HICommand),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5158 NULL, &command);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5159 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5160 if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5161 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5162 SetWRefCon (window, command.commandID);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5163 quit_dialog_event_loop = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5164 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5165 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5166
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5167 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5168 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5169 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5170
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5171 case kEventClassKeyboard:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5172 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5173 OSStatus result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5174 char char_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5175
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5176 result = CallNextEventHandler (next_handler, event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5177 if (result != eventNotHandledErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5178 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5179
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5180 err = GetEventParameter (event, kEventParamKeyMacCharCodes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5181 typeChar, NULL, sizeof (char),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5182 NULL, &char_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5183 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5184 switch (char_code)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5185 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5186 case kEscapeCharCode:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5187 quit_dialog_event_loop = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5188 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5189
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5190 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5191 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5192 UInt32 modifiers, key_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5193
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5194 err = GetEventParameter (event, kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5195 typeUInt32, NULL, sizeof (UInt32),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5196 NULL, &modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5197 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5198 err = GetEventParameter (event, kEventParamKeyCode,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5199 typeUInt32, NULL, sizeof (UInt32),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5200 NULL, &key_code);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5201 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5202 if (mac_quit_char_key_p (modifiers, key_code))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5203 quit_dialog_event_loop = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5204 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5205 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5206 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5207 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5208 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5209
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5210 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5211 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5212 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5213
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5214 if (quit_dialog_event_loop)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5215 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5216 err = QuitEventLoop (GetCurrentEventLoop ());
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5217 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5218 result = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5219 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5220
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5221 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5222 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5223
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5224 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5225 install_dialog_event_handler (window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5226 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5227 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5228 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5229 {{kEventClassCommand, kEventCommandProcess},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5230 {kEventClassKeyboard, kEventRawKeyDown}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5231 static EventHandlerUPP handle_dialog_eventUPP = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5232
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5233 if (handle_dialog_eventUPP == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5234 handle_dialog_eventUPP = NewEventHandlerUPP (mac_handle_dialog_event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5235 return InstallWindowEventHandler (window, handle_dialog_eventUPP,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5236 GetEventTypeCount (specs), specs,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5237 window, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5238 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5239
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5240 static Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5241 pop_down_dialog (arg)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5242 Lisp_Object arg;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5243 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5244 struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5245 WindowRef window = p->pointer;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5246
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5247 BLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5248
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5249 if (popup_activated_flag)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5250 EndAppModalStateForWindow (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5251 DisposeWindow (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5252 popup_activated_flag = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5253
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5254 UNBLOCK_INPUT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5255
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5256 return Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5257 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5258
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5259 /* Pop up the dialog for frame F defined by FIRST_WV and loop until the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5260 dialog pops down.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5261 menu_item_selection will be set to the selection. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5262
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5263 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5264 create_and_show_dialog (f, first_wv)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5265 FRAME_PTR f;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5266 widget_value *first_wv;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5267 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5268 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5269 char *dialog_name, *message;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5270 int nb_buttons, first_group_count, i, result = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5271 widget_value *wv;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5272 short buttons_height, text_height, inner_width, inner_height;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5273 Rect empty_rect, *rects;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5274 WindowRef window = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5275 ControlRef *buttons, default_button = NULL, text;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5276 int specpdl_count = SPECPDL_INDEX ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5277
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5278 dialog_name = first_wv->name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5279 nb_buttons = dialog_name[1] - '0';
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5280 first_group_count = nb_buttons - (dialog_name[4] - '0');
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5281
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5282 wv = first_wv->contents;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5283 message = wv->value;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5284
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5285 wv = wv->next;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5286 SetRect (&empty_rect, 0, 0, 0, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5287
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5288 /* Create dialog window. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5289 err = CreateNewWindow (kMovableModalWindowClass,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5290 kWindowStandardHandlerAttribute,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5291 &empty_rect, &window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5292 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5293 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5294 record_unwind_protect (pop_down_dialog, make_save_value (window, 0));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5295 err = SetThemeWindowBackground (window, kThemeBrushMovableModalBackground,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5296 true);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5297 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5298 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5299 err = SetWindowTitleWithCFString (window, (dialog_name[0] == 'Q'
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5300 ? CFSTR ("Question")
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5301 : CFSTR ("Information")));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5302
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5303 /* Create button controls and measure their optimal bounds. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5304 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5305 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5306 buttons = alloca (sizeof (ControlRef) * nb_buttons);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5307 rects = alloca (sizeof (Rect) * nb_buttons);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5308 for (i = 0; i < nb_buttons; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5309 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5310 CFStringRef label = cfstring_create_with_utf8_cstring (wv->value);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5311
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5312 if (label == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5313 err = memFullErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5314 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5315 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5316 err = CreatePushButtonControl (window, &empty_rect,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5317 label, &buttons[i]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5318 CFRelease (label);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5319 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5320 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5321 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5322 if (!wv->enabled)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5323 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5324 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5325 err = DisableControl (buttons[i]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5326 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5327 err = DeactivateControl (buttons[i]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5328 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5329 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5330 else if (default_button == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5331 default_button = buttons[i];
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5332 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5333 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5334 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5335 SInt16 unused;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5336
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5337 rects[i] = empty_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5338 err = GetBestControlRect (buttons[i], &rects[i], &unused);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5339 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5340 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5341 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5342 UInt32 command_id;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5343
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5344 OffsetRect (&rects[i], -rects[i].left, -rects[i].top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5345 if (rects[i].right < DIALOG_BUTTON_MIN_WIDTH)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5346 rects[i].right = DIALOG_BUTTON_MIN_WIDTH;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5347 else if (rects[i].right > DIALOG_MAX_INNER_WIDTH)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5348 rects[i].right = DIALOG_MAX_INNER_WIDTH;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5349
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5350 command_id = DIALOG_BUTTON_MAKE_COMMAND_ID ((int) wv->call_data);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5351 err = SetControlCommandID (buttons[i], command_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5352 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5353 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5354 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5355 wv = wv->next;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5356 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5357 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5358
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5359 /* Layout buttons. rects[i] is set relative to the bottom-right
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5360 corner of the inner box. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5361 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5362 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5363 short bottom, right, max_height, left_align_shift;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5364
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5365 inner_width = DIALOG_MIN_INNER_WIDTH;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5366 bottom = right = max_height = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5367 for (i = 0; i < nb_buttons; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5368 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5369 if (right - rects[i].right < - inner_width)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5370 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5371 if (i != first_group_count
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5372 && right - rects[i].right >= - DIALOG_MAX_INNER_WIDTH)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5373 inner_width = - (right - rects[i].right);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5374 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5375 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5376 bottom -= max_height + DIALOG_BUTTON_BUTTON_VERTICAL_SPACE;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5377 right = max_height = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5378 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5379 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5380 if (max_height < rects[i].bottom)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5381 max_height = rects[i].bottom;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5382 OffsetRect (&rects[i], right - rects[i].right,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5383 bottom - rects[i].bottom);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5384 right = rects[i].left - DIALOG_BUTTON_BUTTON_HORIZONTAL_SPACE;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5385 if (i == first_group_count - 1)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5386 right -= DIALOG_BUTTON_BUTTON_HORIZONTAL_SPACE;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5387 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5388 buttons_height = - (bottom - max_height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5389
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5390 left_align_shift = - (inner_width + rects[nb_buttons - 1].left);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5391 for (i = nb_buttons - 1; i >= first_group_count; i--)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5392 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5393 if (bottom != rects[i].bottom)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5394 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5395 left_align_shift = - (inner_width + rects[i].left);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5396 bottom = rects[i].bottom;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5397 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5398 OffsetRect (&rects[i], left_align_shift, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5399 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5400 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5401
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5402 /* Create a static text control and measure its bounds. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5403 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5404 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5405 CFStringRef message_string;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5406 Rect bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5407
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5408 message_string = cfstring_create_with_utf8_cstring (message);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5409 if (message_string == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5410 err = memFullErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5411 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5412 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5413 ControlFontStyleRec text_style;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5414
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5415 text_style.flags = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5416 SetRect (&bounds, 0, 0, inner_width, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5417 err = CreateStaticTextControl (window, &bounds, message_string,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5418 &text_style, &text);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5419 CFRelease (message_string);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5420 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5421 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5422 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5423 SInt16 unused;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5424
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5425 bounds = empty_rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5426 err = GetBestControlRect (text, &bounds, &unused);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5427 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5428 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5429 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5430 text_height = bounds.bottom - bounds.top;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5431 if (text_height < DIALOG_TEXT_MIN_HEIGHT)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5432 text_height = DIALOG_TEXT_MIN_HEIGHT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5433 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5434 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5435
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5436 /* Place buttons. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5437 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5438 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5439 inner_height = (text_height + DIALOG_TEXT_BUTTONS_VERTICAL_SPACE
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5440 + buttons_height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5441
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5442 for (i = 0; i < nb_buttons; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5443 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5444 OffsetRect (&rects[i], DIALOG_LEFT_MARGIN + inner_width,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5445 DIALOG_TOP_MARGIN + inner_height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5446 SetControlBounds (buttons[i], &rects[i]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5447 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5448 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5449
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5450 /* Place text. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5451 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5452 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5453 Rect bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5454
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5455 SetRect (&bounds, DIALOG_LEFT_MARGIN, DIALOG_TOP_MARGIN,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5456 DIALOG_LEFT_MARGIN + inner_width,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5457 DIALOG_TOP_MARGIN + text_height);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5458 SetControlBounds (text, &bounds);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5459 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5460
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5461 /* Create the application icon at the upper-left corner. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5462 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5463 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5464 ControlButtonContentInfo content;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5465 ControlRef icon;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5466 static const ProcessSerialNumber psn = {0, kCurrentProcess};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5467 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5468 FSRef app_location;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5469 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5470 ProcessInfoRec pinfo;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5471 FSSpec app_spec;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5472 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5473 SInt16 unused;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5474
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5475 content.contentType = kControlContentIconRef;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5476 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5477 err = GetProcessBundleLocation (&psn, &app_location);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5478 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5479 err = GetIconRefFromFileInfo (&app_location, 0, NULL, 0, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5480 kIconServicesNormalUsageFlag,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5481 &content.u.iconRef, &unused);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5482 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5483 bzero (&pinfo, sizeof (ProcessInfoRec));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5484 pinfo.processInfoLength = sizeof (ProcessInfoRec);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5485 pinfo.processAppSpec = &app_spec;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5486 err = GetProcessInformation (&psn, &pinfo);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5487 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5488 err = GetIconRefFromFile (&app_spec, &content.u.iconRef, &unused);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5489 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5490 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5491 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5492 Rect bounds;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5493
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5494 SetRect (&bounds, DIALOG_ICON_LEFT_MARGIN, DIALOG_ICON_TOP_MARGIN,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5495 DIALOG_ICON_LEFT_MARGIN + DIALOG_ICON_WIDTH,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5496 DIALOG_ICON_TOP_MARGIN + DIALOG_ICON_HEIGHT);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5497 err = CreateIconControl (window, &bounds, &content, true, &icon);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5498 ReleaseIconRef (content.u.iconRef);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5499 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5500 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5501
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5502 /* Show the dialog window and run event loop. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5503 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5504 if (default_button)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5505 err = SetWindowDefaultButton (window, default_button);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5506 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5507 err = install_dialog_event_handler (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5508 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5509 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5510 SizeWindow (window,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5511 DIALOG_LEFT_MARGIN + inner_width + DIALOG_RIGHT_MARGIN,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5512 DIALOG_TOP_MARGIN + inner_height + DIALOG_BOTTOM_MARGIN,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5513 true);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5514 err = RepositionWindow (window, FRAME_MAC_WINDOW (f),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5515 kWindowAlertPositionOnParentWindow);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5516 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5517 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5518 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5519 SetWRefCon (window, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5520 ShowWindow (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5521 BringToFront (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5522 popup_activated_flag = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5523 err = BeginAppModalStateForWindow (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5524 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5525 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5526 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5527 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5528
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5529 quit_dialog_event_loop = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5530 while (1)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5531 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5532 EMACS_TIME next_time = timer_check (1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5533 long secs = EMACS_SECS (next_time);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5534 long usecs = EMACS_USECS (next_time);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5535 EventTimeout timeout;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5536 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5537
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5538 if (secs < 0 || (secs == 0 && usecs == 0))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5539 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5540 /* Sometimes timer_check returns -1 (no timers) even if
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5541 there are timers. So do a timeout anyway. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5542 secs = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5543 usecs = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5544 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5545
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5546 timeout = (secs * kEventDurationSecond
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5547 + usecs * kEventDurationMicrosecond);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5548 err = ReceiveNextEvent (0, NULL, timeout, kEventRemoveFromQueue,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5549 &event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5550 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5551 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5552 SendEventToEventTarget (event, toolbox_dispatcher);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5553 ReleaseEvent (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5554 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5555 #if 0 /* defined (MAC_OSX) */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5556 else if (err != eventLoopTimedOutErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5557 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5558 if (err == eventLoopQuitErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5559 err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5560 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5561 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5562 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5563 /* The return value of ReceiveNextEvent seems to be
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5564 unreliable. Use our own global variable instead. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5565 if (quit_dialog_event_loop)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5566 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5567 err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5568 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5569 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5570 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5571 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5572 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5573 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5574 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5575 UInt32 command_id = GetWRefCon (window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5576
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5577 if (DIALOG_BUTTON_COMMAND_ID_P (command_id))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5578 result = DIALOG_BUTTON_COMMAND_ID_VALUE (command_id);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5579 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5580
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5581 unbind_to (specpdl_count, Qnil);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5582
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5583 menu_item_selection = result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5584 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5585 #else /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5586 #define DIALOG_WINDOW_RESOURCE 130
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5587
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5588 int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5589 mac_dialog (widget_value *wv)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5590 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5591 char *dialog_name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5592 char *prompt;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5593 char **button_labels;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5594 UInt32 *ref_cons;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5595 int nb_buttons;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5596 int left_count;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5597 int i;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5598 int dialog_width;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5599 Rect rect;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5600 WindowRef window_ptr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5601 ControlRef ch;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5602 int left;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5603 EventRecord event_record;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5604 SInt16 part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5605 int control_part_code;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5606 Point mouse;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5607
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5608 dialog_name = wv->name;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5609 nb_buttons = dialog_name[1] - '0';
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5610 left_count = nb_buttons - (dialog_name[4] - '0');
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5611 button_labels = (char **) alloca (sizeof (char *) * nb_buttons);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5612 ref_cons = (UInt32 *) alloca (sizeof (UInt32) * nb_buttons);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5613
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5614 wv = wv->contents;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5615 prompt = (char *) alloca (strlen (wv->value) + 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5616 strcpy (prompt, wv->value);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5617 c2pstr (prompt);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5618
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5619 wv = wv->next;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5620 for (i = 0; i < nb_buttons; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5621 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5622 button_labels[i] = wv->value;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5623 button_labels[i] = (char *) alloca (strlen (wv->value) + 1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5624 strcpy (button_labels[i], wv->value);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5625 c2pstr (button_labels[i]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5626 ref_cons[i] = (UInt32) wv->call_data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5627 wv = wv->next;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5628 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5629
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5630 window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowRef) -1);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5631
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5632 SetPortWindowPort (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5633
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5634 TextFont (0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5635 /* Left and right margins in the dialog are 13 pixels each.*/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5636 dialog_width = 14;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5637 /* Calculate width of dialog box: 8 pixels on each side of the text
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5638 label in each button, 12 pixels between buttons. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5639 for (i = 0; i < nb_buttons; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5640 dialog_width += StringWidth (button_labels[i]) + 16 + 12;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5641
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5642 if (left_count != 0 && nb_buttons - left_count != 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5643 dialog_width += 12;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5644
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5645 dialog_width = max (dialog_width, StringWidth (prompt) + 26);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5646
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5647 SizeWindow (window_ptr, dialog_width, 78, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5648 ShowWindow (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5649
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5650 SetPortWindowPort (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5651
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5652 TextFont (0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5653
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5654 MoveTo (13, 29);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5655 DrawString (prompt);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5656
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5657 left = 13;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5658 for (i = 0; i < nb_buttons; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5659 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5660 int button_width = StringWidth (button_labels[i]) + 16;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5661 SetRect (&rect, left, 45, left + button_width, 65);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5662 ch = NewControl (window_ptr, &rect, button_labels[i], 1, 0, 0, 0,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5663 kControlPushButtonProc, ref_cons[i]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5664 left += button_width + 12;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5665 if (i == left_count - 1)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5666 left += 12;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5667 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5668
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5669 i = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5670 while (!i)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5671 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5672 if (WaitNextEvent (mDownMask, &event_record, 10, NULL))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5673 if (event_record.what == mouseDown)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5674 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5675 part_code = FindWindow (event_record.where, &window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5676 if (part_code == inContent)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5677 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5678 mouse = event_record.where;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5679 GlobalToLocal (&mouse);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5680 control_part_code = FindControl (mouse, window_ptr, &ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5681 if (control_part_code == kControlButtonPart)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5682 if (TrackControl (ch, mouse, NULL))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5683 i = GetControlReference (ch);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5684 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5685 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5686 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5687
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5688 DisposeWindow (window_ptr);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5689
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5690 return i;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5691 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5692 #endif /* not TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5693
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5694
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5695 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5696 Selection support
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5697 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5698
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5699 #if !TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5700 #include <Scrap.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5701 #include <Endian.h>
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5702 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5703
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5704 extern Lisp_Object Vselection_converter_alist;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5705 extern Lisp_Object Qmac_scrap_name, Qmac_ostype;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5706
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5707 static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5708 Selection));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5709
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5710 /* Get a reference to the selection corresponding to the symbol SYM.
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5711 The reference is set to *SEL, and it becomes NULL if there's no
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5712 corresponding selection. Clear the selection if CLEAR_P is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5713 non-zero. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5714
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5715 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5716 mac_get_selection_from_symbol (sym, clear_p, sel)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5717 Lisp_Object sym;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5718 int clear_p;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5719 Selection *sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5720 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5721 OSStatus err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5722 Lisp_Object str = Fget (sym, Qmac_scrap_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5723
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5724 if (!STRINGP (str))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5725 *sel = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5726 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5727 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5728 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5729 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5730 CFStringRef scrap_name = cfstring_create_with_string (str);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5731 OptionBits options = (clear_p ? kScrapClearNamedScrap
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5732 : kScrapGetNamedScrap);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5733
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5734 err = GetScrapByName (scrap_name, options, sel);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5735 CFRelease (scrap_name);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5736 #else /* !MAC_OSX */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5737 if (clear_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5738 err = ClearCurrentScrap ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5739 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5740 err = GetCurrentScrap (sel);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5741 #endif /* !MAC_OSX */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5742 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5743 if (clear_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5744 err = ZeroScrap ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5745 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5746 *sel = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5747 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5748 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5749
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5750 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5751 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5752
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5753 /* Get a scrap flavor type from the symbol SYM. Return 0 if no
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5754 corresponding flavor type. If SEL is non-zero, the return value is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5755 non-zero only when the SEL has the flavor type. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5756
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5757 static ScrapFlavorType
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5758 get_flavor_type_from_symbol (sym, sel)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5759 Lisp_Object sym;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5760 Selection sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5761 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5762 Lisp_Object str = Fget (sym, Qmac_ostype);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5763 ScrapFlavorType flavor_type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5764
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5765 if (STRINGP (str) && SBYTES (str) == 4)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5766 flavor_type = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5767 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5768 flavor_type = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5769
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5770 if (flavor_type && sel)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5771 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5772 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5773 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5774 ScrapFlavorFlags flags;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5775
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5776 err = GetScrapFlavorFlags (sel, flavor_type, &flags);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5777 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5778 flavor_type = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5779 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5780 SInt32 size, offset;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5781
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5782 size = GetScrap (NULL, flavor_type, &offset);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5783 if (size < 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5784 flavor_type = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5785 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5786 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5787
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5788 return flavor_type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5789 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5790
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5791 /* Check if the symbol SYM has a corresponding selection target type. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5792
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5793 int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5794 mac_valid_selection_target_p (sym)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5795 Lisp_Object sym;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5796 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5797 return get_flavor_type_from_symbol (sym, 0) != 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5798 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5799
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5800 /* Clear the selection whose reference is *SEL. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5801
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5802 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5803 mac_clear_selection (sel)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5804 Selection *sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5805 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5806 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5807 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5808 return ClearScrap (sel);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5809 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5810 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5811
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5812 err = ClearCurrentScrap ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5813 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5814 err = GetCurrentScrap (sel);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5815 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5816 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5817 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5818 return ZeroScrap ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5819 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5820 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5821
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5822 /* Get ownership information for SEL. Emacs can detect a change of
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5823 the ownership by comparing saved and current values of the
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5824 ownership information. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5825
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5826 Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5827 mac_get_selection_ownership_info (sel)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5828 Selection sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5829 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5830 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5831 return long_to_cons ((unsigned long) sel);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5832 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5833 ScrapStuffPtr scrap_info = InfoScrap ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5834
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5835 return make_number (scrap_info->scrapCount);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5836 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5837 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5838
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5839 /* Return non-zero if VALUE is a valid selection value for TARGET. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5840
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5841 int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5842 mac_valid_selection_value_p (value, target)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5843 Lisp_Object value, target;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5844 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5845 return STRINGP (value);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5846 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5847
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5848 /* Put Lisp object VALUE to the selection SEL. The target type is
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5849 specified by TARGET. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5850
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5851 OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5852 mac_put_selection_value (sel, target, value)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5853 Selection sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5854 Lisp_Object target, value;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5855 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5856 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (target, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5857
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5858 if (flavor_type == 0 || !STRINGP (value))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5859 return noTypeErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5860
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5861 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5862 return PutScrapFlavor (sel, flavor_type, kScrapFlavorMaskNone,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5863 SBYTES (value), SDATA (value));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5864 #else /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5865 return PutScrap (SBYTES (value), flavor_type, SDATA (value));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5866 #endif /* !TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5867 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5868
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5869 /* Check if data for the target type TARGET is available in SEL. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5870
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5871 int
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5872 mac_selection_has_target_p (sel, target)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5873 Selection sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5874 Lisp_Object target;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5875 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5876 return get_flavor_type_from_symbol (target, sel) != 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5877 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5878
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5879 /* Get data for the target type TARGET from SEL and create a Lisp
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5880 string. Return nil if failed to get data. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5881
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5882 Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5883 mac_get_selection_value (sel, target)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5884 Selection sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5885 Lisp_Object target;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5886 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5887 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5888 Lisp_Object result = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5889 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (target, sel);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5890 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5891 Size size;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5892
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5893 if (flavor_type)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5894 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5895 err = GetScrapFlavorSize (sel, flavor_type, &size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5896 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5897 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5898 do
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5899 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5900 result = make_uninit_string (size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5901 err = GetScrapFlavorData (sel, flavor_type,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5902 &size, SDATA (result));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5903 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5904 result = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5905 else if (size < SBYTES (result))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5906 result = make_unibyte_string (SDATA (result), size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5907 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5908 while (STRINGP (result) && size > SBYTES (result));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5909 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5910 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5911 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5912 Handle handle;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5913 SInt32 size, offset;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5914
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5915 if (flavor_type)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5916 size = GetScrap (NULL, flavor_type, &offset);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5917 if (size >= 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5918 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5919 handle = NewHandle (size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5920 HLock (handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5921 size = GetScrap (handle, flavor_type, &offset);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5922 if (size >= 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5923 result = make_unibyte_string (*handle, size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5924 DisposeHandle (handle);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5925 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5926 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5927
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5928 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5929 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5930
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5931 /* Get the list of target types in SEL. The return value is a list of
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5932 target type symbols possibly followed by scrap flavor type
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5933 strings. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5934
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5935 Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5936 mac_get_selection_target_list (sel)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5937 Selection sel;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5938 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5939 Lisp_Object result = Qnil, rest, target;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5940 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5941 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5942 UInt32 count, i, type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5943 ScrapFlavorInfo *flavor_info = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5944 Lisp_Object strings = Qnil;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5945
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5946 err = GetScrapFlavorCount (sel, &count);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5947 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5948 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5949 err = GetScrapFlavorInfoList (sel, &count, flavor_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5950 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5951 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5952 xfree (flavor_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5953 flavor_info = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5954 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5955 if (flavor_info == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5956 count = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5957 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5958 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5959 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5960 ScrapFlavorType flavor_type = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5961
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5962 if (CONSP (XCAR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5963 && (target = XCAR (XCAR (rest)),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5964 SYMBOLP (target))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5965 && (flavor_type = get_flavor_type_from_symbol (target, sel)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5966 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5967 result = Fcons (target, result);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5968 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5969 for (i = 0; i < count; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5970 if (flavor_info[i].flavorType == flavor_type)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5971 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5972 flavor_info[i].flavorType = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5973 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5974 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5975 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5976 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5977 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5978 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5979 if (flavor_info)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5980 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5981 for (i = 0; i < count; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5982 if (flavor_info[i].flavorType)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5983 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5984 type = EndianU32_NtoB (flavor_info[i].flavorType);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5985 strings = Fcons (make_unibyte_string ((char *) &type, 4), strings);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5986 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5987 result = nconc2 (result, strings);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5988 xfree (flavor_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5989 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5990 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5991
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5992 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5993 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5994
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5995
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5996 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5997 Apple event support
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5998 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5999
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6000 extern pascal OSErr mac_handle_apple_event P_ ((const AppleEvent *,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6001 AppleEvent *, SInt32));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6002 extern void cleanup_all_suspended_apple_events P_ ((void));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6003
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6004 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6005 init_apple_event_handler ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6006 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6007 OSErr err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6008 long result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6009
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6010 /* Make sure we have Apple events before starting. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6011 err = Gestalt (gestaltAppleEventsAttr, &result);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6012 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6013 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6014
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6015 if (!(result & (1 << gestaltAppleEventsPresent)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6016 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6017
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6018 err = AEInstallEventHandler (typeWildCard, typeWildCard,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6019 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6020 NewAEEventHandlerUPP (mac_handle_apple_event),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6021 #else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6022 NewAEEventHandlerProc (mac_handle_apple_event),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6023 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6024 0L, false);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6025 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6026 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6027
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6028 atexit (cleanup_all_suspended_apple_events);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6029 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6030
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6031
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6032 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6033 Drag and drop support
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6034 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6035
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6036 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6037 extern Lisp_Object Vmac_dnd_known_types;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6038
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6039 static pascal OSErr mac_do_track_drag P_ ((DragTrackingMessage, WindowRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6040 void *, DragRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6041 static pascal OSErr mac_do_receive_drag P_ ((WindowRef, void *, DragRef));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6042 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6043 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6044
80517
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6045 static OSErr
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6046 create_apple_event_from_drag_ref (drag, num_types, types, result)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6047 DragRef drag;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6048 UInt32 num_types;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6049 const FlavorType *types;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6050 AppleEvent *result;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6051 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6052 OSErr err;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6053 UInt16 num_items;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6054 AppleEvent items;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6055 long index;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6056 char *buf = NULL;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6057
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6058 err = CountDragItems (drag, &num_items);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6059 if (err != noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6060 return err;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6061 err = AECreateList (NULL, 0, false, &items);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6062 if (err != noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6063 return err;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6064
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6065 for (index = 1; index <= num_items; index++)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6066 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6067 ItemReference item;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6068 DescType desc_type = typeNull;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6069 Size size;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6070
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6071 err = GetDragItemReferenceNumber (drag, index, &item);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6072 if (err == noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6073 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6074 int i;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6075
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6076 for (i = 0; i < num_types; i++)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6077 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6078 err = GetFlavorDataSize (drag, item, types[i], &size);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6079 if (err == noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6080 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6081 buf = xrealloc (buf, size);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6082 err = GetFlavorData (drag, item, types[i], buf, &size, 0);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6083 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6084 if (err == noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6085 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6086 desc_type = types[i];
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6087 break;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6088 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6089 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6090 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6091 err = AEPutPtr (&items, index, desc_type,
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6092 desc_type != typeNull ? buf : NULL,
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6093 desc_type != typeNull ? size : 0);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6094 if (err != noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6095 break;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6096 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6097 if (buf)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6098 xfree (buf);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6099
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6100 if (err == noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6101 {
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6102 err = create_apple_event (0, 0, result); /* Dummy class and ID. */
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6103 if (err == noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6104 err = AEPutParamDesc (result, keyDirectObject, &items);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6105 if (err != noErr)
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6106 AEDisposeDesc (result);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6107 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6108
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6109 AEDisposeDesc (&items);
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6110
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6111 return err;
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6112 }
086b32514483 (Vmac_ts_script_language_on_focus)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 80464
diff changeset
6113
80446
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6114 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6115 mac_store_drag_event (window, mouse_pos, modifiers, desc)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6116 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6117 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6118 SInt16 modifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6119 const AEDesc *desc;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6120 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6121 struct input_event buf;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6122
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6123 EVENT_INIT (buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6124
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6125 buf.kind = DRAG_N_DROP_EVENT;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6126 buf.modifiers = mac_to_emacs_modifiers (modifiers, 0);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6127 buf.timestamp = TickCount () * (1000 / 60);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6128 XSETINT (buf.x, mouse_pos.h);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6129 XSETINT (buf.y, mouse_pos.v);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6130 XSETFRAME (buf.frame_or_window, mac_window_to_frame (window));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6131 buf.arg = mac_aedesc_to_lisp (desc);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6132 kbd_buffer_store_event (&buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6133 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6134
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6135 static pascal OSErr
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6136 mac_do_track_drag (message, window, refcon, drag)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6137 DragTrackingMessage message;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6138 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6139 void *refcon;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6140 DragRef drag;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6141 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6142 OSErr err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6143 static int can_accept;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6144 UInt16 num_items, index;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6145
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6146 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6147 return dragNotAcceptedErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6148
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6149 switch (message)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6150 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6151 case kDragTrackingEnterHandler:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6152 err = CountDragItems (drag, &num_items);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6153 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6154 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6155 can_accept = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6156 for (index = 1; index <= num_items; index++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6157 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6158 ItemReference item;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6159 FlavorFlags flags;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6160 Lisp_Object rest;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6161
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6162 err = GetDragItemReferenceNumber (drag, index, &item);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6163 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6164 continue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6165 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6166 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6167 Lisp_Object str;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6168 FlavorType type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6169
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6170 str = XCAR (rest);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6171 if (!(STRINGP (str) && SBYTES (str) == 4))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6172 continue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6173 type = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6174
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6175 err = GetFlavorFlags (drag, item, type, &flags);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6176 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6177 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6178 can_accept = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6179 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6180 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6181 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6182 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6183 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6184
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6185 case kDragTrackingEnterWindow:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6186 if (can_accept)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6187 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6188 RgnHandle hilite_rgn = NewRgn ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6189
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6190 if (hilite_rgn)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6191 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6192 Rect r;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6193
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6194 GetWindowPortBounds (window, &r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6195 OffsetRect (&r, -r.left, -r.top);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6196 RectRgn (hilite_rgn, &r);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6197 ShowDragHilite (drag, hilite_rgn, true);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6198 DisposeRgn (hilite_rgn);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6199 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6200 SetThemeCursor (kThemeCopyArrowCursor);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6201 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6202 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6203
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6204 case kDragTrackingInWindow:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6205 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6206
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6207 case kDragTrackingLeaveWindow:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6208 if (can_accept)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6209 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6210 HideDragHilite (drag);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6211 SetThemeCursor (kThemeArrowCursor);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6212 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6213 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6214
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6215 case kDragTrackingLeaveHandler:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6216 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6217 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6218
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6219 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6220 return dragNotAcceptedErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6221 return noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6222 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6223
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6224 static pascal OSErr
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6225 mac_do_receive_drag (window, refcon, drag)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6226 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6227 void *refcon;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6228 DragRef drag;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6229 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6230 OSErr err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6231 int num_types, i;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6232 Lisp_Object rest, str;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6233 FlavorType *types;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6234 AppleEvent apple_event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6235 Point mouse_pos;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6236 SInt16 modifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6237
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6238 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6239 return dragNotAcceptedErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6240
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6241 num_types = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6242 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6243 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6244 str = XCAR (rest);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6245 if (STRINGP (str) && SBYTES (str) == 4)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6246 num_types++;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6247 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6248
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6249 types = xmalloc (sizeof (FlavorType) * num_types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6250 i = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6251 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6252 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6253 str = XCAR (rest);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6254 if (STRINGP (str) && SBYTES (str) == 4)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6255 types[i++] = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6256 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6257
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6258 err = create_apple_event_from_drag_ref (drag, num_types, types,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6259 &apple_event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6260 xfree (types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6261
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6262 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6263 err = GetDragMouse (drag, &mouse_pos, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6264 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6265 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6266 GlobalToLocal (&mouse_pos);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6267 err = GetDragModifiers (drag, NULL, NULL, &modifiers);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6268 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6269 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6270 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6271 UInt32 key_modifiers = modifiers;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6272
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6273 err = AEPutParamPtr (&apple_event, kEventParamKeyModifiers,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6274 typeUInt32, &key_modifiers, sizeof (UInt32));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6275 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6276
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6277 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6278 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6279 mac_store_drag_event (window, mouse_pos, 0, &apple_event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6280 AEDisposeDesc (&apple_event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6281 mac_wakeup_from_rne ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6282 return noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6283 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6284 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6285 return dragNotAcceptedErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6286 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6287 #endif /* TARGET_API_MAC_CARBON */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6288
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6289 static OSErr
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6290 install_drag_handler (window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6291 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6292 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6293 OSErr err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6294
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6295 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6296 if (mac_do_track_dragUPP == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6297 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6298 if (mac_do_receive_dragUPP == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6299 mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6300
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6301 err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6302 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6303 err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6304 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6305
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6306 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6307 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6308
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6309 static void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6310 remove_drag_handler (window)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6311 WindowRef window;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6312 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6313 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6314 if (mac_do_track_dragUPP)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6315 RemoveTrackingHandler (mac_do_track_dragUPP, window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6316 if (mac_do_receive_dragUPP)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6317 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6318 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6319 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6320
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6321 #if TARGET_API_MAC_CARBON
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6322 /* Return default value for mac-dnd-known-types. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6323
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6324 Lisp_Object
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6325 mac_dnd_default_known_types ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6326 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6327 Lisp_Object result = list4 (build_string ("hfs "), build_string ("utxt"),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6328 build_string ("TEXT"), build_string ("TIFF"));
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6329
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6330 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6331 result = Fcons (build_string ("furl"), result);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6332 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6333
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6334 return result;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6335 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6336 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6337
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6338
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6339 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6340 Services menu support
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6341 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6342
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6343 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6344 extern Lisp_Object Qservice, Qpaste, Qperform;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6345 extern Lisp_Object Vmac_service_selection;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6346
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6347 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6348 mac_store_service_event (event)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6349 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6350 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6351 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6352 Lisp_Object id_key;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6353 int num_params;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6354 const EventParamName *names;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6355 const EventParamType *types;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6356 static const EventParamName names_pfm[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6357 {kEventParamServiceMessageName, kEventParamServiceUserData};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6358 static const EventParamType types_pfm[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6359 {typeCFStringRef, typeCFStringRef};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6360
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6361 switch (GetEventKind (event))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6362 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6363 case kEventServicePaste:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6364 id_key = Qpaste;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6365 num_params = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6366 names = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6367 types = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6368 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6369
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6370 case kEventServicePerform:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6371 id_key = Qperform;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6372 num_params = sizeof (names_pfm) / sizeof (names_pfm[0]);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6373 names = names_pfm;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6374 types = types_pfm;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6375 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6376
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6377 default:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6378 abort ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6379 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6380
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6381 err = mac_store_event_ref_as_apple_event (0, 0, Qservice, id_key,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6382 event, num_params,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6383 names, types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6384
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6385 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6386 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6387
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6388 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6389 copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6390 ScrapRef from_scrap, to_scrap;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6391 ScrapFlavorType flavor_type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6392 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6393 OSStatus err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6394 Size size, size_allocated;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6395 char *buf = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6396
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6397 err = GetScrapFlavorSize (from_scrap, flavor_type, &size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6398 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6399 buf = xmalloc (size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6400 while (buf)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6401 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6402 size_allocated = size;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6403 err = GetScrapFlavorData (from_scrap, flavor_type, &size, buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6404 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6405 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6406 xfree (buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6407 buf = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6408 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6409 else if (size_allocated < size)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6410 buf = xrealloc (buf, size);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6411 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6412 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6413 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6414 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6415 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6416 if (buf == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6417 err = memFullErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6418 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6419 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6420 err = PutScrapFlavor (to_scrap, flavor_type, kScrapFlavorMaskNone,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6421 size, buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6422 xfree (buf);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6423 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6424 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6425
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6426 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6427 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6428
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6429 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6430 mac_handle_service_event (call_ref, event, data)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6431 EventHandlerCallRef call_ref;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6432 EventRef event;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6433 void *data;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6434 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6435 OSStatus err = noErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6436 ScrapRef cur_scrap, specific_scrap;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6437 UInt32 event_kind = GetEventKind (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6438 CFMutableArrayRef copy_types, paste_types;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6439 CFStringRef type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6440 Lisp_Object rest;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6441 ScrapFlavorType flavor_type;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6442
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6443 /* Check if Vmac_service_selection is a valid selection that has a
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6444 corresponding scrap. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6445 if (!SYMBOLP (Vmac_service_selection))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6446 err = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6447 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6448 err = mac_get_selection_from_symbol (Vmac_service_selection, 0, &cur_scrap);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6449 if (!(err == noErr && cur_scrap))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6450 return eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6451
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6452 switch (event_kind)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6453 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6454 case kEventServiceGetTypes:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6455 /* Set paste types. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6456 err = GetEventParameter (event, kEventParamServicePasteTypes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6457 typeCFMutableArrayRef, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6458 sizeof (CFMutableArrayRef), NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6459 &paste_types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6460 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6461 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6462
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6463 for (rest = Vselection_converter_alist; CONSP (rest);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6464 rest = XCDR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6465 if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6466 && (flavor_type =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6467 get_flavor_type_from_symbol (XCAR (XCAR (rest)), 0)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6468 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6469 type = CreateTypeStringWithOSType (flavor_type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6470 if (type)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6471 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6472 CFArrayAppendValue (paste_types, type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6473 CFRelease (type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6474 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6475 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6476
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6477 /* Set copy types. */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6478 err = GetEventParameter (event, kEventParamServiceCopyTypes,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6479 typeCFMutableArrayRef, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6480 sizeof (CFMutableArrayRef), NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6481 &copy_types);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6482 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6483 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6484
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6485 if (NILP (Fx_selection_owner_p (Vmac_service_selection)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6486 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6487 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6488 goto copy_all_flavors;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6489
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6490 case kEventServiceCopy:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6491 err = GetEventParameter (event, kEventParamScrapRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6492 typeScrapRef, NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6493 sizeof (ScrapRef), NULL, &specific_scrap);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6494 if (err != noErr
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6495 || NILP (Fx_selection_owner_p (Vmac_service_selection)))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6496 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6497 err = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6498 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6499 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6500
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6501 copy_all_flavors:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6502 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6503 UInt32 count, i;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6504 ScrapFlavorInfo *flavor_info = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6505 ScrapFlavorFlags flags;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6506
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6507 err = GetScrapFlavorCount (cur_scrap, &count);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6508 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6509 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6510 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6511 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6512 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6513 xfree (flavor_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6514 flavor_info = NULL;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6515 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6516 if (flavor_info == NULL)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6517 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6518
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6519 for (i = 0; i < count; i++)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6520 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6521 flavor_type = flavor_info[i].flavorType;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6522 err = GetScrapFlavorFlags (cur_scrap, flavor_type, &flags);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6523 if (err == noErr && !(flags & kScrapFlavorMaskSenderOnly))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6524 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6525 if (event_kind == kEventServiceCopy)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6526 err = copy_scrap_flavor_data (cur_scrap, specific_scrap,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6527 flavor_type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6528 else /* event_kind == kEventServiceGetTypes */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6529 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6530 type = CreateTypeStringWithOSType (flavor_type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6531 if (type)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6532 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6533 CFArrayAppendValue (copy_types, type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6534 CFRelease (type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6535 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6536 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6537 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6538 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6539 xfree (flavor_info);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6540 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6541 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6542
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6543 case kEventServicePaste:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6544 case kEventServicePerform:
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6545 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6546 int data_exists_p = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6547
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6548 err = GetEventParameter (event, kEventParamScrapRef, typeScrapRef,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6549 NULL, sizeof (ScrapRef), NULL,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6550 &specific_scrap);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6551 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6552 err = mac_clear_selection (&cur_scrap);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6553 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6554 for (rest = Vselection_converter_alist; CONSP (rest);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6555 rest = XCDR (rest))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6556 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6557 if (! (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))))
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6558 continue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6559 flavor_type = get_flavor_type_from_symbol (XCAR (XCAR (rest)),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6560 specific_scrap);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6561 if (flavor_type == 0)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6562 continue;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6563 err = copy_scrap_flavor_data (specific_scrap, cur_scrap,
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6564 flavor_type);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6565 if (err == noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6566 data_exists_p = 1;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6567 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6568 if (!data_exists_p)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6569 err = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6570 else
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6571 err = mac_store_service_event (event);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6572 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6573 break;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6574 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6575
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6576 if (err != noErr)
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6577 err = eventNotHandledErr;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6578 return err;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6579 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6580
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6581 static OSStatus
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6582 install_service_handler ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6583 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6584 static const EventTypeSpec specs[] =
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6585 {{kEventClassService, kEventServiceGetTypes},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6586 {kEventClassService, kEventServiceCopy},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6587 {kEventClassService, kEventServicePaste},
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6588 {kEventClassService, kEventServicePerform}};
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6589
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6590 return InstallApplicationEventHandler (NewEventHandlerUPP
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6591 (mac_handle_service_event),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6592 GetEventTypeCount (specs),
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6593 specs, NULL, NULL);
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6594 }
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6595 #endif /* MAC_OSX */
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6596
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6597
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6598 /***********************************************************************
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6599 Initialization
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6600 ***********************************************************************/
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6601
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6602 void
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6603 mac_toolbox_initialize ()
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6604 {
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6605 any_help_event_p = 0;
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6606
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6607 init_menu_bar ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6608
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6609 #ifdef MAC_OSX
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6610 init_apple_event_handler ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6611 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6612 #if USE_MAC_TSM
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6613 init_tsm ();
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6614 #endif
cb749087dcc9 New file.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6615 }
80464
8db0c1448dec Add arch tagline
Miles Bader <miles@gnu.org>
parents: 80446
diff changeset
6616
8db0c1448dec Add arch tagline
Miles Bader <miles@gnu.org>
parents: 80446
diff changeset
6617 /* arch-tag: 71a597a8-6e9f-47b0-8b89-5a5ae3e16516
8db0c1448dec Add arch tagline
Miles Bader <miles@gnu.org>
parents: 80446
diff changeset
6618 (do not change this comment) */