1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright 2013 LibreOffice contributors.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_TOUCH_TOUCH_H
#define INCLUDED_TOUCH_TOUCH_H
#include <config_features.h>
#define MOBILE_MAX_ZOOM_IN 600
#define MOBILE_MAX_ZOOM_OUT 80
#define MOBILE_ZOOM_SCALE_MULTIPLIER 10000
#if !HAVE_FEATURE_DESKTOP
// Let's try this way: Use Quartz 2D types for iOS, and LO's basegfx
// types for others, when/if this API is used for others. But of
// course, it is quite likely that some degree of redesign is needed
// at such a stage anyway...
#ifdef IOS
#include <premac.h>
#include <CoreGraphics/CoreGraphics.h>
#include <postmac.h>
#else
#include <basegfx/range/b2ibox.hxx>
#endif
#ifdef __cplusplus
extern "C" {
#if 0
} // To avoid an editor indenting all inside the extern "C"
#endif
#endif
// These functions are the interface between the upper GUI layers of a
// LibreOffice-based app on a touch platform app and the lower "core"
// layers, used in cases where the core parts need to call
// functionality in the upper parts or vice versa.
//
// Thus there are two classes of functions here:
//
// 1) Those to be implemented in the upper layer and called by the
// lower layer. Prefixed by touch_ui_. The same API is used on each
// such platform. There are called from low level LibreOffice
// code. Note that these are just declared here in a header for a
// "touch" module, the per-platform implementations are elsewhere.
void touch_ui_damaged(int minX, int minY, int width, int height);
void touch_ui_show_keyboard();
void touch_ui_hide_keyboard();
bool touch_ui_keyboard_visible();
// Dialogs, work in progress, no clear plan yet what to do
typedef enum {
MLODialogMessage,
MLODialogInformation,
MLODialogWarning,
MLODialogError,
MLODialogQuery
} MLODialogKind;
typedef enum {
MLODialogOK,
MLODialogCancel,
MLODialogNo,
MLODialogYes,
MLODialogRetry,
MLODialogIgnore,
} MLODialogResult;
MLODialogResult touch_ui_dialog_modal(MLODialogKind kind, const char *message);
typedef enum {
MLOSelectionNone,
MLOSelectionText,
MLOSelectionGraphic
} MLOSelectionKind;
#ifdef IOS
typedef CGRect MLORect;
#else
typedef basegfx::B2IBox MLORect;
#endif
typedef long long MLOContentSizeDimension;
struct MLOContentSize {
MLOContentSizeDimension width;
MLOContentSizeDimension height;
};
typedef struct MLOContentSize MLOContentSize;
CG_INLINE MLOContentSize
MLOContentSizeMake(MLOContentSizeDimension width, MLOContentSizeDimension height)
{
MLOContentSize size; size.width = width; size.height = height; return size;
}
void touch_ui_selection_start(MLOSelectionKind kind,
const void *documentHandle,
MLORect *rectangles,
int rectangleCount,
void *preview);
void touch_ui_selection_resize_done(bool success,
const void *documentHandle,
MLORect *rectangles,
int rectangleCount);
void touch_ui_selection_none();
// 2) Those implemented in the lower layers to be called by the upper
// layer, in cases where we don't want to include a bunch of the
// "normal" LibreOffice C++ headers in an otherwise purely Objective-C
// CocoaTouch-based source file. Of course it depends on the case
// where that is wanted, and this all is work in progress. Prefixed by
// touch_lo_. All these are called on the UI thread and except for
// those so marked schedule work to be done asynchronously on the LO
// thread.
typedef enum { DOWN, MOVE, UP} MLOMouseButtonState;
typedef enum { NONE, SHIFT, META } MLOModifiers;
typedef int MLOModifierMask;
void touch_lo_keyboard_did_hide();
void touch_lo_set_view_size(int width, int height);
void touch_lo_tap(int x, int y);
void touch_lo_mouse(int x, int y, MLOMouseButtonState state, MLOModifierMask modifiers);
void touch_lo_pan(int deltaX, int deltaY);
void touch_lo_zoom(int x, int y, float scale);
void touch_lo_keyboard_input(int c);
/** Draw part of the document.
tilePosX, tilePosY, tileWidth, tileHeight address the part of the document to be drawn.
context, contextHeight, contextWidth specify where to draw.
*/
void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, int tilePosX, int tilePosY, int tileWidth, int tileHeight);
void touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeight, size_t sourceBytesPerRow, void * target, size_t targetWidth, size_t targetHeight);
MLOContentSize touch_lo_get_content_size();
void touch_lo_mouse_drag(int x, int y, MLOMouseButtonState state);
// Move the start of the selection to (x,y)
void touch_lo_selection_start_move(const void *documentHandle,
int x,
int y);
// Move the end of the selection to (x,y)
void touch_lo_selection_end_move(const void *documentHandle,
int x,
int y);
void touch_lo_selection_attempt_resize(const void *documentHandle,
MLORect *selectedRectangles,
int numberOfRectangles);
// Special case: synchronous: waits for the rendering to complete
void touch_lo_render_windows(void *context, int minX, int minY, int width, int height);
// Special case: This is the function that is called in the newly
// created LO thread to run the LO code.
void touch_lo_runMain();
#ifdef __cplusplus
}
#endif
#endif // HAVE_FEATURE_DESKTOP
#endif // INCLUDED_TOUCH_TOUCH_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|