60
62
return QSize (p.x1*c, p.x2*c);
66
to_qfont (int style, QFont font) {
67
if (style & WIDGET_STYLE_MINI) // use smaller text font inside widget
68
font.setPointSize(10);
69
if (style & WIDGET_STYLE_MONOSPACED) // use monospaced font inside widget
70
font.setFixedPitch(true); //FIXME?
71
//if (style & WIDGET_STYLE_GREY) // use grey text font
72
// font.set += "color: #414141";
73
if (style & WIDGET_STYLE_PRESSED) // indicate that a button is currently pressed
75
if (style & WIDGET_STYLE_INERT) // only render but don't associate any action to widget
77
if (style & WIDGET_STYLE_BUTTON) // indicate that a button should explicitly rendered as a button
79
if (style & WIDGET_STYLE_BOLD)
65
parse_tm_style(int style) {
86
parse_tm_style (int style) {
67
88
if (style & WIDGET_STYLE_MINI) // use smaller text font inside widget
68
89
sheet += "font-size: 10pt;";
69
90
if (style & WIDGET_STYLE_MONOSPACED) // use monospaced font inside widget
70
91
sheet += "font-family: \"monospace\";";
71
92
if (style & WIDGET_STYLE_GREY) // use grey text font
72
sheet += "font-color: #eeeeee";
93
sheet += "color: #414141;";
73
94
if (style & WIDGET_STYLE_PRESSED) // indicate that a button is currently pressed
75
96
if (style & WIDGET_STYLE_INERT) // only render but don't associate any action to widget
103
/*! Try to convert a TeXmacs lenght (em, px, w, h) in a QSize.
105
* Uses the widget current size to compute relative sizes as specified with "1w"
106
* Should not affect the widget size in that particular case.
107
* FIXME: should we use the constant PIXEL somewhere?
124
/*! Try to convert a TeXmacs lenght (em, px, w, h) into a QSize.
126
This uses the widget's current size to compute relative sizes as specified
127
with "FFw", where FF is the string representation of a double.
128
A value of "1w" should not affect the widget size.
130
FIXME: does 1w mean 100% of the contents' size or 100% of the available size?
110
qt_decode_length (string width, QWidget* qwid) {
133
qt_decode_length (QWidget* qwid, string width, string height) {
113
size= qwid->minimumSizeHint();
136
size = qwid->minimumSizeHint();
115
138
gui_maximal_extents (size.rwidth(), size.rheight());
140
// Width as a function of the default width
117
141
if (ends (width, "w") && is_double (width (0, N(width) - 1))) {
118
double x= as_double (width (0, N(width) - 1));
142
double x = as_double (width (0, N(width) - 1));
119
143
size.rwidth() *= x;
145
// Width as a function of the default height
121
146
else if (ends (width, "h") && is_double (width (0, N(width) - 1))) {
122
double y= as_double (width (0, N(width) - 1));
147
double y = as_double (width (0, N(width) - 1));
148
size.rwidth() = y * size.height();
125
151
else if (ends (width, "em") && is_double (width (0, N(width) - 2))) {
126
double x= as_double (width (0, N(width) - 2));
152
double x = as_double (width (0, N(width) - 2));
128
154
size.setWidth(x * qwid->fontInfo().pointSize());
130
156
size.setWidth(x * QApplication::font().pointSize());
159
// Absolute pixel units
133
160
else if (ends (width, "px") && is_double (width (0, N(width) - 2))) {
134
double x= as_double (width (0, N(width) - 2));
161
double x = as_double (width (0, N(width) - 2));
135
162
size.setWidth(x);
165
// Height as a function of the default width
166
if (ends (height, "w") && is_double (height (0, N(height) - 1))) {
167
double x = as_double (height (0, N(height) - 1));
168
size.rheight() = x * size.width();
170
// Height as a function of the default height
171
else if (ends (height, "h") && is_double (width (0, N(width) - 1))) {
172
double y = as_double (height (0, N(height) - 1));
175
else if (ends (height, "em") && is_double (height (0, N(height) - 2))) {
176
double y = as_double (height (0, N(height) - 2));
178
size.setHeight(y * qwid->fontInfo().pointSize());
180
size.setHeight(y * QApplication::font().pointSize());
183
else if (ends (height, "px") && is_double (height (0, N(height) - 2))) {
184
double y = as_double (height (0, N(height) - 2));
192
// used only by to_qkeysequence
194
conv_sub (string ks) {
197
r = replace (r, "S-", "Shift+");
198
r = replace (r, "C-", "Meta+");
199
r = replace (r, "A-", "Alt+");
200
r = replace (r, "M-", "Ctrl+");
201
//r = replace (r, "K-", "");
202
r = replace (r, " ", ",");
204
r = replace (r, "S-", "Shift+");
205
r = replace (r, "C-", "Ctrl+");
206
r = replace (r, "A-", "Alt+");
207
r = replace (r, "M-", "Meta+");
208
//r = replace (r, "K-", "");
209
r = replace (r, " ", ",");
211
if (N(r) == 1 || (N(r) > 2 && r[N(r)-2] == '+')) {
212
if (is_locase (r[N(r)-1]))
213
r= r (0, N(r)-1) * upcase_all (r (N(r)-1, N(r)));
214
else if (is_upcase (r[N(r)-1]))
215
r= r (0, N(r)-1) * "Shift+" * upcase_all (r (N(r)-1, N(r)));
221
to_qkeysequence (string s) {
224
for (k=0; k<=N(s); k++)
225
if (k == N(s) || s[k] == ' ') {
226
r << conv_sub (s (i, k));
229
return QKeySequence(to_qstring(r));
141
233
from_qrect (const QRect & rect) {
142
234
SI c1, c2, c3, c4;