annotate src/gui_kde_x11.cc @ 116:973ccf576e2c

updated for version 7.0041
author vimboss
date Mon, 17 Jan 2005 22:21:07 +0000
parents 014ba200db86
children 5c65f9e56459
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
2 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
4 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
5 * Do ":help uganda" in Vim to read copying and usage conditions.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
6 * Do ":help credits" in Vim to see a list of people who contributed.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
7 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
8
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
9 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
10 * Porting to KDE(2) was done by
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
11 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
12 * (C) 2000 by Thomas Capricelli <orzel@freehackers.org>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
13 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
14 * Please visit http://freehackers.org/kvim for other vim- or
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
15 * kde-related coding.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
16 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
17 * $Id$
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
18 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
19 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
20
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
21 #include <qscrollbar.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
22 #include <qcstring.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
23 #include <qdatetime.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
24 #include <qcursor.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
25 #include <qfontmetrics.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
26 #include <qpaintdevice.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
27 #include <qclipboard.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
28 #include <qregexp.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
29 #include <kaboutkde.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
30 #include <kiconloader.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
31 #include <kfontdialog.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
32 #include <kmessagebox.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
33 #include <dcopclient.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
34 #include <kwin.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
35 #include <kmenubar.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
36 #include <kconfig.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
37 #if (QT_VERSION>=300)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
38 #include <qnamespace.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
39 #include <ktip.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
40 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
41 #include <qpopupmenu.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
42 #include <qpainter.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
43 #include <qtextcodec.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
44 #include <qfontmetrics.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
45 #include <qfont.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
46
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
47
20
4ac1dce8dd5e updated for version 7.0012
vimboss
parents: 16
diff changeset
48 #include "gui_kde_wid.h"
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
49
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
50
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
51 extern "C" {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
52 #include "vim.h"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
53 #include "version.h"
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
54 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
55
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
56 #include <stdio.h>
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
57
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
58 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
59 * global variable for KDE, we can't put them in Gui, cause there are C++ types
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
60 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
61 VimMainWindow *vmw = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
62 SBPool *sbpool = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
63 QString *argServerName = 0;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
64
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
65 #ifdef FEAT_MOUSESHAPE
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
66 /* The last set mouse pointer shape is remembered, to be used when it goes
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
67 * from hidden to not hidden. */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
68 static int last_shape = 0;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
69 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
70
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
71 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
72 * Arguments handled by KDE internally.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
73 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
74
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
75 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
76 static int tip = 0; // 1 no dialog, 0 use it if enabled in conf,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
77 // 2 force the tip
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
78 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
79 static int reverse = 0; // 0 bg : white, 1 : bg : black
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
80 QString *startfont;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
81 QSize *startsize;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
82 static int gui_argc = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
83 static char **gui_argv = NULL;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
84
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
85 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
86 * Parse the GUI related command-line arguments. Any arguments used are
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
87 * deleted from argv, and *argc is decremented accordingly. This is called
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
88 * when vim is started, whether or not the GUI has been started.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
89 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
90 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
91 gui_mch_prepare(int *argc, char **argv)// {{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
92 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
93 // copy args for KDE/Qt
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
94 gui_argc = 0;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
95
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
96 // this one is not really good as all options are not for KDE/Qt ...
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
97 gui_argv = (char **)lalloc((long_u)(*argc * sizeof(char *)), FALSE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
98 if (gui_argv == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
99 return;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
100 gui_argv[gui_argc++] = argv[0];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
101
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
102 int found = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
103 for (int i = 1; i < *argc ; i++)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
104 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
105 if (found != 2)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
106 found = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
107 else
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
108 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
109 found = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
110 // remove from the list of argv
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
111 if (--*argc > i)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
112 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
113 mch_memmove(&argv[i], &argv[i + 1],
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
114 (*argc - i) * sizeof(char *));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
115 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
116 i--;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
117 continue;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
118 }
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
119
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
120 if (strcmp(argv[i], "--servername") == 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
121 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
122 argServerName = new QString(argv[i+1]); // to get the serverName now
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
123 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
124 #if QT_VERSION>+300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
125 if (strcmp(argv[i], "-tip") == 0 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
126 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
127 tip = 2;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
128 found = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
129 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
130 if (strcmp(argv[i], "-notip") == 0 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
131 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
132 tip = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
133 found = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
134 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
135 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
136 if (strcmp(argv[i], "-black") == 0 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
137 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
138 reverse = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
139 found = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
140 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
141 /* replaced by -black */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
142 /* if (strcmp(argv[i], "-rv") == 0 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
143 * {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
144 reverse = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
145 found = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
146 }*/
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
147 if (strcmp(argv[i], "-font") == 0 || strcmp(argv[i], "-fn") == 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
148 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
149 startfont = new QString(argv[i+1]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
150 found = 2;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
151 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
152 if (strcmp(argv[i], "-geometry") == 0 || strcmp(argv[i], "-geom") == 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
153 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
154 found = 2;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
155 QString text(argv[i + 1]);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
156 QStringList list = QStringList::split(QChar('x'), text);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
157 startsize = new QSize(list[0].toInt(), list[1].toInt());
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
158 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
159 if (strcmp(argv[i], "-display") == 0) //XXX: this does not work,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
160 // too many -display options in main.c !
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
161 // ask Bram ...
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
162 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
163 gui_argv[gui_argc++] = strdup("--display");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
164 gui_argv[gui_argc++] = argv[i+1];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
165 found = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
166 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
167 if (strcmp(argv[i], "--display") == 0 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
168 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
169 gui_argv[gui_argc++] = argv[i];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
170 gui_argv[gui_argc++] = argv[i+1];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
171 found = 2;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
172 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
173 //KDE/Qt options with no args
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
174 if (strcmp(argv[i], "--help-kde") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
175 || strcmp(argv[i], "--help-qt") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
176 || strcmp(argv[i], "--help-all") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
177 || strcmp(argv[i], "--reverse") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
178 || strcmp(argv[i], "--author") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
179 // || strcmp(argv[i], "--version") == 0 //disabled we need these for kcmvim
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
180 // || strcmp(argv[i], "-v") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
181 || strcmp(argv[i], "--license") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
182 || strcmp(argv[i], "--cmap") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
183 || strcmp(argv[i], "--nograb") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
184 || strcmp(argv[i], "--dograb") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
185 || strcmp(argv[i], "--sync") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
186 || strcmp(argv[i], "--noxim") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
187 || strcmp(argv[i], "--nocrashhandler") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
188 || strcmp(argv[i], "--waitforwm") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
189 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
190 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
191 gui_argv[gui_argc++] = argv[i];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
192 found = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
193 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
194 //this outputs KDE and Vim versions :)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
195 if (strcmp(argv[i], "--version") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
196 || strcmp(argv[i], "-v") == 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
197 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
198 gui_argv[gui_argc++] = argv[i];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
199 }
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
200
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
201
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
202 // KDE/Qt options with one arg
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
203 if (strcmp(argv[i], "--session") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
204 || strcmp(argv[i], "--ncols") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
205 || strcmp(argv[i], "--bg") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
206 || strcmp(argv[i], "--background") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
207 || strcmp(argv[i], "--fg") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
208 || strcmp(argv[i], "--foreground") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
209 || strcmp(argv[i], "--btn") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
210 || strcmp(argv[i], "--name") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
211 || strcmp(argv[i], "--title") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
212 || strcmp(argv[i], "--inputstyle") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
213 || strcmp(argv[i], "--im") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
214 || strcmp(argv[i], "--caption") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
215 || strcmp(argv[i], "--icon") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
216 || strcmp(argv[i], "--miniicon") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
217 || strcmp(argv[i], "--config") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
218 || strcmp(argv[i], "--dcopserver") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
219 || strcmp(argv[i], "--style") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
220 || strcmp(argv[i], "--geometry") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
221 || strcmp(argv[i], "--smkey") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
222 || strcmp(argv[i], "-smkey") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
223 || strcmp(argv[i], "-session") == 0
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
224 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
225 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
226 gui_argv[gui_argc++] = argv[i];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
227 gui_argv[gui_argc++] = argv[i + 1];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
228 found = 2;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
229 }
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
230
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
231 // remove from the list of argv
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
232 if (found >= 1 && --*argc > i)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
233 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
234 mch_memmove(&argv[i], &argv[i + 1], (*argc - i) * sizeof(char *));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
235 i--;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
236 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
237 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
238 KCmdLineArgs::init(gui_argc, gui_argv, "kvim",
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
239 I18N_NOOP("Vim inside KDE"), VIM_VERSION_SHORT);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
240 }// }}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
241
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
242 /****************************************************************************
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
243 * Focus handlers:
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
244 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
245
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
246 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
247 * Initialises time intervals for the cursor blinking
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
248 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
249 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
250 gui_mch_set_blinking(long waittime, long on, long off)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
251 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
252 gui.w->set_blink_time(waittime, on, off);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
253 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
254
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
255 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
256 * Stop the cursor blinking. Show the cursor if it wasn't shown.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
257 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
258 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
259 gui_mch_stop_blink()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
260 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
261 gui.w->stop_cursor_blinking();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
262 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
263
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
264 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
265 * Start the cursor blinking. If it was already blinking, this restarts the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
266 * waiting time and shows the cursor.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
267 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
268 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
269 gui_mch_start_blink()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
270 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
271 gui.w->start_cursor_blinking();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
272 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
273
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
274 #ifdef FEAT_MZSCHEME
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
275 void
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
276 mzscheme_kde_start_timer()//{{{
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
277 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
278 gui.w->enable_mzscheme_threads();
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
279 }//}}}
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
280 void
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
281 mzscheme_kde_stop_timer()//{{{
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
282 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
283 gui.w->disable_mzscheme_threads();
16
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
284 }//}}}
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
285 #endif
3ba373b54370 updated for version 7.0008
vimboss
parents: 11
diff changeset
286
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
287 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
288 * Check if the GUI can be started. Called before gvimrc is sourced.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
289 * Return OK or FAIL.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
290 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
291 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
292 gui_mch_init_check(void)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
293 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
294 gui.dpy = qt_xdisplay();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
295 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
296 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
297
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
298 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
299 * Initialise the X GUI. Create all the windows, set up all the call-backs etc.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
300 * Returns OK for success, FAIL when the GUI can't be started.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
301 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
302 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
303 gui_mch_init()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
304 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
305 (void) new KApplication();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
306 KApplication::kApplication()->dcopClient()->registerAs(
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
307 KApplication::kApplication()->name(), false);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
308 // dbf("%s %s", KGlobal::locale()->language().latin1(), KLocale::defaultLanguage().latin1());
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
309
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
310 vmw = new VimMainWindow("KVim", 0);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
311 vmw->setFrameBorderWidth(0);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
312 kapp->setMainWidget(vmw);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
313 kapp->setTopWidget(vmw);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
314
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
315 sbpool = new SBPool;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
316
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
317 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
318 vmw->connect(kapp->clipboard(), SIGNAL(selectionChanged()),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
319 vmw, SLOT(clipboard_selection_update()));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
320 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
321 vmw->connect(kapp->clipboard(), SIGNAL(dataChanged()),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
322 vmw, SLOT(clipboard_data_update()));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
323 clip_lose_selection(&clip_plus);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
324 clip_lose_selection(&clip_star);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
325
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
326 gui.in_focus = FALSE; // will be updated
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
327
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
328 if (reverse)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
329 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
330 gui.def_norm_pixel = gui_get_color((char_u *)"White");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
331 gui.def_back_pixel = gui_get_color((char_u *)"Black");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
332 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
333 gui.w->setEraseColor(QColor(Qt::black));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
334 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
335 gui.w->setBackgroundColor(QColor(Qt::black));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
336 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
337 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
338 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
339 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
340 gui.def_norm_pixel = gui_get_color((char_u *)"Black");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
341 gui.def_back_pixel = gui_get_color((char_u *)"White");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
342 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
343 gui.w->setEraseColor(QColor(Qt::white));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
344 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
345 gui.w->setBackgroundColor(QColor(Qt::white));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
346 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
347 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
348
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
349 gui.norm_pixel = gui.def_norm_pixel;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
350 gui.back_pixel = gui.def_back_pixel;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
351
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
352 gui.border_width = 1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
353 gui.border_offset = 1;//gui.border_width;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
354 gui.scrollbar_width = SB_DEFAULT_WIDTH;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
355 gui.scrollbar_height = SB_DEFAULT_WIDTH;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
356
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
357 //gui.menu_height = vmw->menuBar()->height()+1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
358 //gui.toolbar_height = vmw->toolBar()->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
359
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
360 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
361 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
362
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
363
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
364 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
365 * Called when the foreground or background color has been changed.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
366 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
367 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
368 gui_mch_new_colors()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
369 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
370 QColor rgb;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
371 rgb.setRgb(gui.back_pixel);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
372 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
373 gui.w->setEraseColor(rgb);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
374 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
375 gui.w->setBackgroundColor(rgb);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
376 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
377 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
378
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
379 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
380 * Open the GUI window which was created by a call to gui_mch_init().
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
381 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
382 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
383 gui_mch_open()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
384 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
385 gui.dpy = qt_xdisplay();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
386 set_normal_colors();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
387
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
388 /* Check that none of the colors are the same as the background color */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
389 gui_check_colors();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
390
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
391 /* Get the colors for the highlight groups (gui_check_colors() might have
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
392 * changed them).
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
393 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
394 highlight_gui_started(); /* re-init colors and fonts */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
395 #ifdef FEAT_MENU
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
396 vmw->w->menu = new QPopupMenu(vmw);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
397
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
398 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
399 vmw->w->menu->insertItem(SmallIcon("ktip"), i18n("&Tip of the day..."),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
400 vmw, SLOT(showTipOfTheDay()));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
401 vmw->w->menu->insertSeparator();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
402 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
403 if (vmw->have_tearoff)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
404 vmw->w->menu->insertTearOffHandle(0, 0);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
405 vmw->w->menu->insertItem(i18n("&Report Bug ..."),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
406 vmw, SLOT(showBugReport()));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
407 vmw->w->menu->insertSeparator();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
408 vmw->w->menu->insertItem(SmallIcon("kvim"), i18n("&About KVim..."),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
409 vmw, SLOT(showAboutApplication()));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
410 vmw->w->menu->insertItem(SmallIcon("about_kde"), i18n("About &KDE..."),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
411 vmw, SLOT(showAboutKDE()));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
412 vmw->menuBar()->insertItem("&KVim", vmw->w->menu);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
413 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
414 if (startfont != NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
415 gui_mch_init_font((char_u*)startfont->latin1(), FALSE);
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
416
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
417 if (startsize != NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
418 vmw->resize(startsize->width(), startsize->height());
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
419
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
420 gui_mch_update_codec();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
421
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
422 if (kapp->isRestored())
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
423 if (KMainWindow::canBeRestored(1))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
424 vmw->restore(1);
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
425
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
426 vmw->show();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
427 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
428 if (tip == 2)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
429 KTipDialog::showTip(vmw, QString::null, true);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
430 else if (tip == 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
431 KTipDialog::showTip(vmw);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
432 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
433
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
434 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
435 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
436
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
437 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
438 gui_mch_exit(int rc)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
439 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
440 kapp->quit();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
441 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
442
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
443 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
444 * Get the position of the top left corner of the window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
445 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
446 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
447 gui_mch_get_winpos(int *x, int *y)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
448 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
449 *x = vmw->x();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
450 *y = vmw->y();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
451 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
452 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
453
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
454 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
455 * Set the position of the top left corner of the window to the given
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
456 * coordinates.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
457 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
458 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
459 gui_mch_set_winpos(int x, int y)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
460 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
461 vmw->move(x, y);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
462 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
463
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
464 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
465 * Set the windows size.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
466 * ->resize VimWidget
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
467 * ->resize vmw (block any events generated from here)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
468 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
469 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
470 gui_mch_set_shellsize(int width, int height,//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
471 int min_width, int min_height,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
472 int base_width, int base_height)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
473 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
474 //resize VimWidget
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
475 vmw->w->resize(width, height);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
476
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
477 //resize vmw
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
478 int vheight, vwidth;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
479 vheight = height;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
480 vwidth = width;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
481
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
482 if (gui.which_scrollbars[SBAR_LEFT])
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
483 vwidth += gui.scrollbar_width;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
484 if (gui.which_scrollbars[SBAR_RIGHT])
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
485 vwidth += gui.scrollbar_width;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
486 if (gui.which_scrollbars[SBAR_BOTTOM])
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
487 vheight += gui.scrollbar_height;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
488
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
489 if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
490 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
491 && !vmw->menuBar()->isTopLevelMenu()
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
492 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
493 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
494 vheight += vmw->menuBar()->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
495 #ifdef FEAT_TOOLBAR
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
496 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
497 && (vmw->toolBar()->barPos() == KToolBar::Top
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
498 || vmw->toolBar()->barPos() == KToolBar::Bottom))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
499 vheight += vmw->toolBar()->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
500
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
501 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
502 && (vmw->toolBar()->barPos() == KToolBar::Left
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
503 || vmw->toolBar()->barPos() == KToolBar::Right))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
504 vwidth += vmw->toolBar()->width();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
505 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
506 vmw->lock();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
507 vmw->resize(vwidth, vheight);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
508 gui_mch_update();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
509 //size should be nearly perfect, update baseSize and sizeIncrement
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
510 vmw->setBaseSize(base_width, vmw->menuBar()->height() + 1
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
511 + vmw->toolBar()->height() + gui.char_height * 2);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
512 vmw->setSizeIncrement((( int )(gui.char_width / 2) * 2), gui.char_height);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
513 vmw->unlock();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
514 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
515
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
516
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
517 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
518 * The screen size is used to make sure the initial window doesn't get bigger
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
519 * then the screen. This subtracts some room for menubar, toolbar and window
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
520 * decorations.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
521 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
522 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
523 gui_mch_get_screen_dimensions(int *screen_w, int *screen_h)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
524 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
525 *screen_w = kapp->desktop()->width();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
526 *screen_h = kapp->desktop()->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
527 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
528
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
529 #if defined(FEAT_MENU) || defined(PROTO)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
530 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
531 gui_mch_enable_menu(int showit)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
532 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
533 if (showit)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
534 vmw->menuBar()->show();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
535 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
536 vmw->menuBar()->hide();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
537 vmw->resize(vmw->width(), vmw->height());
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
538 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
539 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
540
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
541
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
542 #if defined(FEAT_TOOLBAR) || defined(PROTO)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
543 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
544 gui_mch_show_toolbar(int showit)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
545 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
546 if (showit)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
547 vmw->toolBar()->show();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
548 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
549 vmw->toolBar()->hide();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
550 vmw->resize(vmw->width(), vmw->height());
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
551 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
552 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
553
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
554 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
555 * Put up a font dialog and return the selected font name in allocated memory.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
556 * "oldval" is the previous value.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
557 * Return NULL when cancelled.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
558 */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
559
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
560 char_u *
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
561 gui_mch_font_dialog(char_u *oldval)//{{{
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
562 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
563 QFont myFont(vmw->w->font());
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
564 if (gui.fontname)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
565 gui.fontname = NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
566
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
567 int result = KFontDialog::getFont(myFont, true);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
568 if (result != KFontDialog::Accepted)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
569 return NULL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
570
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
571 // myFont.setFixedPitch(true);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
572 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
573 QString n = myFont.toString();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
574 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
575 QString n = KVimUtils::toString(&myFont);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
576 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
577 n.replace(QRegExp(","), "/");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
578 gui.fontname = (char_u *)strdup((const char *)n);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
579 n.replace(QRegExp(" "), "\\ ");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
580 n = QString("To set this font as your default font for KVim, edit your ~/.gvimrc file and add the following lines : \nif has(\"gui_kde\")\nset guifont=")+n+QString("\nendif");// \n OR \n use the control center of KDE and choose the correct fixed font");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
581
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
582 //display a message box which explains how to save your font settings
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
583 KMessageBox::information(vmw, n, "Font Selection", "kvimselectfont");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
584
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
585 return vim_strsave(gui.fontname);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
586 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
587
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
588 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
589 * Initialise vim to use the font with the given name.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
590 * Return FAIL if the font could not be loaded, OK otherwise.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
591 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
592 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
593 gui_mch_init_font(char_u * font_name, int fontset)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
594 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
595 QString fontname;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
596 GuiFont font = NULL;
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
597
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
598 if (font_name == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
599 {
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
600 #if 0
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
601 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
602 KConfig *base = KGlobal::config();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
603 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
604 KConfigBase *base = KGlobal::config();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
605 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
606 base->setGroup("General");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
607 if (!base->hasKey("fixed"))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
608 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
609 KMessageBox::error(KApplication::kApplication()->mainWidget(),"Cannot load default fixed font\n\nConfigure fonts in KDE Control Center.\n(Just click 'Choose...', 'OK' and then 'Apply')");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
610 return FAIL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
611 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
612 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
613 QString f = base->readEntry("fixed");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
614 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
615 QFont ft = base->readFontEntry("fixed", NULL);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
616 QString f = KVimUtils::toString(&ft);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
617 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
618 font_name = (char_u*)strdup(f.latin1()); //latin1 ?
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
619 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
620 font_name = (char_u*)strdup("misc-fixed/10/-1/5/50/0/0/0/1/0");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
621 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
622 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
623 fontname = (const char *)font_name;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
624 /* fontname.replace(QRegExp("/"), ",");
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
625 font = new QFont();
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
626 font->fromString( fontname );
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
627 */
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
628 #ifdef FEAT_XFONTSET
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
629 if (fontset)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
630 font = gui_mch_get_fontset(font_name, TRUE, TRUE);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
631 if (font == NULL)
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
632 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
633 font = gui_mch_get_font(font_name, FALSE);
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
634
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
635 if (font == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
636 return FAIL;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
637 if (fontname.contains('*') && fontname.contains('-'))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
638 return FAIL;
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
639
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
640 gui_mch_free_font(gui.norm_font);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
641 #ifdef FEAT_XFONTSET
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
642 gui_mch_free_fontset(gui.fontset);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
643 gui.fontset = NOFONTSET;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
644 if (fontset)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
645 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
646 gui.fontset = font;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
647 gui.norm_font = NOFONT;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
648 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
649 else
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
650 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
651 gui.norm_font = font;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
652
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
653 /* Compute the width of the character cell. Some fonts include
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
654 * double-width characters. Use the width of ASCII characters to find
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
655 * out if this is so. */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
656 QFontMetrics f(*font);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
657 int width_max = 0;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
658 for (char c = 32; c < 127; c++)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
659 if (width_max < f.width((QChar)c))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
660 width_max = f.width((QChar)c);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
661 if (width_max <= f.maxWidth() / 2)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
662 width_max = f.maxWidth() / 2;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
663 gui.char_width = width_max;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
664 gui.char_height = f.height() + p_linespace;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
665 gui.char_ascent = f.ascent() + p_linespace;
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
666
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
667 //check values, just to make sure and avoid a crash
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
668 if (gui.char_width <= 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
669 gui.char_width = 8;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
670 if (gui.char_height <= 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
671 gui.char_height = 1;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
672
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
673 hl_set_font_name(font_name);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
674
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
675 vmw->w->setFont(*font);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
676
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
677 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
678 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
679
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
680 GuiFont
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
681 gui_mch_get_font(char_u * name, int report_error)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
682 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
683 QString fontname((const char *)name);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
684 if (!gui.in_use || name == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
685 return NOFONT;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
686 if (fontname.contains('*') && fontname.contains('-'))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
687 return NOFONT; // XFLD names not allowed anymore
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
688 QFont *myFont = new QFont();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
689 fontname.replace(QRegExp("/"), ",");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
690 // myFont->setRawMode(TRUE);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
691
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
692 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
693 myFont->fromString(fontname);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
694 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
695 KVimUtils::fromString(myFont, fontname);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
696 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
697 myFont->setFixedPitch(true);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
698 if (!myFont->fixedPitch())
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
699 dbf("Non fixed-width font");
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
700 return (GuiFont) myFont;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
701 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
702
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 42
diff changeset
703 #if defined(FEAT_EVAL) || defined(PROTO)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
704 /*
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
705 * Return the name of font "font" in allocated memory.
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
706 * Don't know how to get the actual name, thus use the provided name.
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
707 */
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
708 char_u *
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
709 gui_mch_get_fontname(GuiFont font, char_u *name)//{{{
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
710 {
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
711 if (name == NULL)
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
712 return NULL;
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
713 return vim_strsave(name);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
714 }//}}}
44
af1bcb9a13c0 updated for version 7.0027
vimboss
parents: 42
diff changeset
715 #endif
37
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
716
fdf55076c53f updated for version 7.0022
vimboss
parents: 23
diff changeset
717 /*
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
718 * Set the current text font.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
719 * Since we create all GC on demand, we use just gui.current_font to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
720 * indicate the desired current font.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
721 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
722 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
723 gui_mch_set_font(GuiFont font)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
724 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
725 gui.current_font = font;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
726 gui.w->painter->setFont(*(gui.current_font));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
727 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
728
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
729 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
730 * If a font is not going to be used, free its structure.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
731 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
732 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
733 gui_mch_free_font(GuiFont font)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
734 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
735 if (font)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
736 delete font; // this is a QFont , we can delete it :)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
737 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
738
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
739 GuiFontset
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
740 gui_mch_get_fontset(char_u *name, int report_error, int fixed_width)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
741 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
742 return (GuiFontset)gui_mch_get_font(name, report_error);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
743 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
744
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
745 void
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
746 gui_mch_set_fontset(GuiFontset fontset)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
747 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
748 gui_mch_set_font((GuiFont)fontset);
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
749 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
750
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
751 void
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
752 gui_mch_free_fontset(GuiFontset fontset)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
753 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
754 if (fontset)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
755 delete fontset;
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
756 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
757
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
758 void
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
759 gui_mch_settitle(char_u *title, char_u *icon)//{{{
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
760 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
761 if (!gui.in_use) /* can't do this when GUI not running */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
762 return;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
763 vmw->setPlainCaption((const char *)title);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
764 QPixmap p((const char *)icon);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
765 vmw->setIcon(p); //FIXME
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
766 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
767
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
768 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
769 * Return the Pixel value (color) for the given color name. This routine was
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
770 * pretty much taken from example code in the Silicon Graphics OSF/Motif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
771 * Programmer's Guide.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
772 * Return -1 for error.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
773 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
774 guicolor_T
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
775 gui_mch_get_color(char_u * name)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
776 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
777 int i;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
778 static char *(vimnames[][2]) =
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
779 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
780 /* A number of colors that some X11 systems don't have */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
781 {"LightRed", "#FFA0A0"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
782 {"LightGreen", "#80FF80"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
783 {"LightMagenta", "#FFA0FF"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
784 {"DarkCyan", "#008080"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
785 {"DarkBlue", "#0000C0"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
786 {"DarkRed", "#C00000"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
787 {"DarkMagenta", "#C000C0"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
788 {"DarkGrey", "#C0C0C0"},
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
789 {NULL, NULL}
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
790 };
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
791
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
792 if (!gui.in_use) /* can't do this when GUI not running */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
793 return (guicolor_T)(-1);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
794
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
795 QColor _color((const char *)name);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
796
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
797 if (_color.isValid())
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
798 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
799 // return (_color.red() << 16) + ((_color.green() << 8))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
800 // + (_color.blue());
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
801 return _color.rgb();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
802 // return (guicolor_T) _color.pixel();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
803 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
804
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
805 /* add a few builtin names */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
806 for (i = 0;; ++i)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
807 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
808 if (vimnames[i][0] == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
809 return (guicolor_T)(-1);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
810 if (STRICMP(name, vimnames[i][0]) == 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
811 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
812 name = (char_u *) vimnames[i][1];
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
813 return gui_mch_get_color(name);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
814 }
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
815 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
816
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
817 return (guicolor_T)(-1); // dead code, should not be reached..
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
818 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
819
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
820 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
821 * Set the current text foreground color.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
822 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
823 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
824 gui_mch_set_fg_color(guicolor_T color)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
825 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
826 QColor rgb;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
827 rgb.setRgb(color);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
828 gui.w->painter->setPen(rgb);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
829 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
830
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
831 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
832 * Set the current text background color.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
833 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
834 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
835 gui_mch_set_bg_color(guicolor_T color)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
836 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
837 QColor rgb;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
838 rgb.setRgb(color);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
839 gui.w->painter->setBackgroundColor(rgb);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
840 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
841
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
842 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
843 * Use the blank mouse pointer or not.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
844 *
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
845 * hide: TRUE = use blank ptr, FALSE = use parent ptr
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
846 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
847 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
848 gui_mch_mousehide(int hide)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
849 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
850 if (hide == gui.pointer_hidden)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
851 return;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
852 //#ifdef FEAT_MOUSESHAPE
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
853 // if (!hide) mch_set_mouse_shape(last_shape);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
854 //#else
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
855 # if (QT_VERSION<300)
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
856 gui.w->setCursor((hide)?BlankCursor:ArrowCursor);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
857 # else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
858 gui.w->setCursor((hide)?Qt::BlankCursor:Qt::ArrowCursor);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
859 # endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
860 //#endif
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
861 gui.pointer_hidden = hide;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
862 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
863
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
864 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
865 gui_mch_update_codec()
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
866 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
867 #ifdef FEAT_MBYTE
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
868 if (!gui.in_use)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
869 return;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
870 vmw->codec = QTextCodec::codecForName((const char *)p_enc);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
871 if (vmw->codec == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
872 vmw->codec = QTextCodec::codecForName(
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
873 KVimUtils::convertEncodingName(QString((const char*)p_enc)));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
874 if (vmw->codec == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
875 vmw->codec = QTextCodec::codecForLocale();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
876 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
877 vmw->codec = QTextCodec::codecForLocale();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
878 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
879 if (vmw->codec == NULL)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
880 vmw->codec = QTextCodec::codecForName("ISO-8859-1"); //fallback
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
881 }
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
882
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
883 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
884 gui_mch_draw_string(int row, int col, char_u * s, int len, int flags)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
885 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
886 QString text = vmw->codec->toUnicode((const char *)s, len);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
887 gui.w->draw_string(TEXT_X(col), TEXT_Y(row), text, text.length(), flags);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
888 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
889
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
890 #if defined(FEAT_TITLE) || defined(PROTO)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
891 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
892 * Return the text window-id and display. Only required for X-based GUI's
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
893 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
894 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
895 gui_get_x11_windis(Window * win, Display ** dis)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
896 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
897 *win = /*vmw*/gui.w->winId();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
898 *dis = qt_xdisplay();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
899 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
900 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
901 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
902
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
903 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
904 gui_mch_beep()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
905 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
906 kapp->beep();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
907 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
908
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
909 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
910 gui_mch_flash(int msec)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
911 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
912 gui.w->flash();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
913 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
914
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
915 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
916 * Invert a rectangle from row r, column c, for nr rows and nc columns.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
917 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
918 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
919 gui_mch_invert_rectangle(int r, int c, int nr, int nc)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
920 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
921 bitBlt(gui.w,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
922 FILL_X(c), FILL_Y(r),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
923 gui.w,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
924 FILL_X(c), FILL_Y(r),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
925 (nc) * gui.char_width,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
926 (nr) * gui.char_height,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
927 Qt::NotROP, // raster Operation
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
928 true); // ignoreMask
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
929 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
930
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
931 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
932 * Iconify the GUI window.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
933 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
934 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
935 gui_mch_iconify()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
936 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
937 vmw->showMinimized();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
938 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
939
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
940 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
941 * Draw a cursor without focus.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
942 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
943 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
944 gui_mch_draw_hollow_cursor(guicolor_T color)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
945 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
946 QPainter p(gui.w);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
947 p.setPen(color);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
948
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
949 p.drawRect(FILL_X(gui.col), FILL_Y(gui.row), gui.char_width - 1,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
950 gui.char_height - 1);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
951 p.end();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
952 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
953
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
954 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
955 * Draw part of a cursor, "w" pixels wide, and "h" pixels high, using
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
956 * color "color".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
957 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
958 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
959 gui_mch_draw_part_cursor(int w, int h, guicolor_T color)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
960 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
961 QPainter p(gui.w);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
962 p.setPen(color);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
963 p.fillRect(
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
964 FILL_X(gui.col),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
965 FILL_Y(gui.row) + gui.char_height - h + 1,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
966 w, h - 2, QColor( color, color));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
967 p.drawRect(FILL_X(gui.col), FILL_Y(gui.row) + gui.char_height - h
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
968 + (int)p_linespace / 2,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
969 w, h - (int)p_linespace);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
970 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
971
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
972
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
973 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
974 * Catch up with any queued X11 events. This may put keyboard input into the
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
975 * input buffer, call resize call-backs, trigger timers etc. If there is
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
976 * nothing in the X11 event queue (& no timers pending), then we return
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
977 * immediately.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
978 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
979 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
980 gui_mch_update()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
981 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
982 kapp->processEvents();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
983 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
984
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
985
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
986 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
987 * GUI input routine called by gui_wait_for_chars(). Waits for a character
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
988 * from the keyboard.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
989 * wtime == -1 Wait forever.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
990 * wtime == 0 This should never happen.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
991 * wtime > 0 Wait wtime milliseconds for a character.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
992 * Returns OK if a character was found to be available within the given time,
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
993 * or FAIL otherwise.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
994 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
995 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
996 gui_mch_wait_for_chars(long wtime)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
997 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
998 // malte@kde.org's gift to KVim ;), thanks to him :) for this hard to find bug
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
999 if (wtime > 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1000 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1001 gui.w->wait(wtime);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1002 while (vim_is_input_buf_empty() && !gui.w->wait_done)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1003 kapp->processOneEvent();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1004 return vim_is_input_buf_empty() ? FAIL : OK;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1005 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1006 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1007 while (vim_is_input_buf_empty())
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1008 kapp->processOneEvent();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1009
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1010 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1011 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1012
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1013
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1014 /****************************************************************************
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1015 * Output drawing routines.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1016 ****************************************************************************/
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1017
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1018
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1019 /* Flush any output to the screen */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1020 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1021 gui_mch_flush()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1022 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1023 kapp->flushX();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1024 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1025
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1026 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1027 * Clear a rectangular region of the screen from text pos (row1, col1) to
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1028 * (row2, col2) inclusive.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1029 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1030 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1031 gui_mch_clear_block(int row1, int col1, int row2, int col2)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1032 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1033 gui.w->erase(FILL_X(col1), FILL_Y(row1),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1034 (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1035 (row2 - row1 + 1) * gui.char_height);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1036 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1037
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1038 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1039 gui_mch_clear_all(void)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1040 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1041 gui.w->erase();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1042 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1043
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1044
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1045 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1046 * Delete the given number of lines from the given row, scrolling up any
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1047 * text further down within the scroll region.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1048 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1049 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1050 gui_mch_delete_lines(int row, int num_lines)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1051 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1052 if (num_lines <= 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1053 return;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1054
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1055 if (row + num_lines > gui.scroll_region_bot)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1056 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1057 /* Scrolled out of region, just blank the lines out */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1058 gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1059 gui.scroll_region_right);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1060 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1061 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1062 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1063 bitBlt(gui.w,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1064 FILL_X(gui.scroll_region_left), FILL_Y(row),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1065 gui.w,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1066 FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1067 gui.char_width * (gui.scroll_region_right
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1068 - gui.scroll_region_left + 1) + 1,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1069 gui.char_height * (gui.scroll_region_bot - row - num_lines + 1),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1070 Qt::CopyROP, // raster Operation
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1071 true); // ignoreMask
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1072
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1073 /* Update gui.cursor_row if the cursor scrolled or copied over */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1074 if (gui.cursor_row >= row)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1075 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1076 if (gui.cursor_row < row + num_lines)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1077 gui.cursor_is_valid = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1078 else if (gui.cursor_row <= gui.scroll_region_bot)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1079 gui.cursor_row -= num_lines;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1080 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1081
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1082 gui_clear_block(gui.scroll_region_bot - num_lines + 1,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1083 gui.scroll_region_left,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1084 gui.scroll_region_bot, gui.scroll_region_right);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1085 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1086 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1087
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1088 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1089 * Insert the given number of lines before the given row, scrolling down any
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1090 * following text within the scroll region.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1091 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1092 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1093 gui_mch_insert_lines(int row, int num_lines)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1094 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1095 if (num_lines <= 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1096 return;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1097
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1098 if (row + num_lines > gui.scroll_region_bot)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1099 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1100 /* Scrolled out of region, just blank the lines out */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1101 gui_clear_block(row, gui.scroll_region_left, gui.scroll_region_bot,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1102 gui.scroll_region_right - 1);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1103 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1104 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1105 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1106 bitBlt(gui.w,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1107 FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1108 gui.w,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1109 FILL_X(gui.scroll_region_left), FILL_Y(row),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1110 gui.char_width * ( gui.scroll_region_right
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1111 - gui.scroll_region_left + 1 ) + 1,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1112 gui.char_height * (gui.scroll_region_bot - row - num_lines + 1),
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1113 Qt::CopyROP, // raster Operation
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1114 true); // ignoreMask
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1115
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1116 /* Update gui.cursor_row if the cursor scrolled or copied over */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1117 if (gui.cursor_row >= gui.row)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1118 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1119 if (gui.cursor_row <= gui.scroll_region_bot - num_lines)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1120 gui.cursor_row += num_lines;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1121 else if (gui.cursor_row <= gui.scroll_region_bot)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1122 gui.cursor_is_valid = FALSE;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1123 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1124
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1125 gui_clear_block(row, gui.scroll_region_left, row + num_lines - 1,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1126 gui.scroll_region_right);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1127 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1128 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1129
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1130 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1131 * X Selection stuff, for cutting and pasting text to other windows.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1132 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1133 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1134 clip_mch_request_selection(VimClipboard *cbd)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1135 {
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1136 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1137 if (cbd == &clip_star)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1138 kapp->clipboard()->setSelectionMode(true);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1139 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1140 QString selection = kapp->clipboard()->text();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1141
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1142 QCString unistring = vmw->codec->fromUnicode(selection);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1143 clip_yank_selection(MCHAR, (char_u *)(const char*)unistring,
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1144 (long)unistring.length(), cbd);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1145 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1146 if (cbd == &clip_star)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1147 kapp->clipboard()->setSelectionMode(false);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1148 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1149 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1150
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1151 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1152 clip_mch_lose_selection(VimClipboard *cbd)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1153 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1154 // Don't need to do anything here
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1155 gui_mch_update();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1156 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1157
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1158 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1159 * Check whatever we allready own the selection.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1160 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1161 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1162 clip_mch_own_selection(VimClipboard *cbd)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1163 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1164 if (kapp->clipboard()->ownsSelection())
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1165 return OK;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1166 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1167 {
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1168 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1169 kapp->clipboard()->setSelectionMode(true);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1170 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1171 return OK;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1172 }
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1173 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1174
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1175 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1176 * Send the current selection to the clipboard.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1177 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1178 void
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1179 clip_mch_set_selection(VimClipboard *cbd)//{{{
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1180 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1181 char_u *data;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1182 long_u length;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1183
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1184 clip_get_selection(cbd);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1185 if (clip_convert_selection(&data, &length, cbd) < 0)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1186 return;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1187
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1188 QString selection((const char *)data);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1189 // We must turncate the string because it is not
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1190 // null terminated
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1191 selection.truncate((uint) length);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1192
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1193 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1194 if (cbd == &clip_star)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1195 kapp->clipboard()->setSelectionMode(true);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1196 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1197 kapp->clipboard()->setText(selection);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1198 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1199 kapp->clipboard()->setSelectionMode(false);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1200 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1201 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1202
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1203
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1204 #if defined(FEAT_MENU) || defined(PROTO)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1205 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1206 * Make a menu item appear either active or not active (grey or not grey).
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1207 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1208 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1209 gui_mch_menu_grey(vimmenu_T * menu, int grey)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1210 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1211 if (!menu || !menu->parent || !menu->parent->widget)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1212 return;
75
388f285bda1b updated for version 7.0031
vimboss
parents: 44
diff changeset
1213 menu->parent->widget->setItemEnabled((long)menu, !grey);
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1214 gui_mch_update();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1215 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1216
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1217 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1218 * Make menu item hidden or not hidden.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1219 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1220 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1221 gui_mch_menu_hidden(vimmenu_T * menu, int hidden)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1222 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1223 // FIXME: cannot be fixed AFAIK
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1224 // it's hard to remove an item in a QPopupMenu
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1225 gui_mch_menu_grey(menu, hidden);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1226 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1227
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1228 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1229 * This is called after setting all the menus to grey/hidden or not.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1230 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1231 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1232 gui_mch_draw_menubar()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1233 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1234 // nothing to do under kde
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1235 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1236 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1237
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1238 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1239 * Scrollbar stuff.
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1240 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1241 void
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1242 gui_mch_enable_scrollbar(scrollbar_T *sb, int flag)//{{{
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1243 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1244 if (!sb->w)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1245 return;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1246 int width = gui.w->width();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1247 int height = gui.w->height();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1248 int neww = vmw->width();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1249 int newh = vmw->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1250
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1251 if (gui.which_scrollbars[SBAR_LEFT])
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1252 width += gui.scrollbar_width;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1253 if (gui.which_scrollbars[SBAR_RIGHT])
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1254 width += gui.scrollbar_width;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1255 if (gui.which_scrollbars[SBAR_BOTTOM])
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1256 height += gui.scrollbar_height;
23
3f44e9abe4ec updated for version 7.0015
vimboss
parents: 20
diff changeset
1257
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1258 if (vmw->menuBar()->isVisible() && vmw->menuBar()->isEnabled()
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1259 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1260 && !vmw->menuBar()->isTopLevelMenu()
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1261 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1262 )
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1263 height += vmw->menuBar()->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1264 #ifdef FEAT_TOOLBAR
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1265 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1266 && (vmw->toolBar()->barPos() == KToolBar::Top
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1267 || vmw->toolBar()->barPos() == KToolBar::Bottom))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1268 height += vmw->toolBar()->height();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1269
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1270 if (vmw->toolBar()->isVisible() && vmw->toolBar()->isEnabled()
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1271 && (vmw->toolBar()->barPos() == KToolBar::Left
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1272 || vmw->toolBar()->barPos() == KToolBar::Right))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1273 width += vmw->toolBar()->width();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1274 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1275 if (abs(vmw->width() - width) > 5
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1276 && (sb->type == SBAR_LEFT || sb->type == SBAR_RIGHT))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1277 neww = width;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1278 if (abs(vmw->height() - height) > 5 && (sb->type == SBAR_BOTTOM))
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1279 newh = height;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1280
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1281 if (flag)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1282 sb->w->show();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1283 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1284 sb->w->hide();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1285 gui_mch_update();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1286 vmw->lock();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1287 vmw->resize(neww, newh);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1288 vmw->unlock();
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1289 gui_mch_update();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1290 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1291
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1292 /*
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1293 * Return the RGB value of a pixel as "#RRGGBB".
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1294 */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1295 long_u
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1296 gui_mch_get_rgb(guicolor_T pixel)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1297 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1298 // QColor c(pixel, pixel);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1299 // return (c.red() << 16) + ((c.green() << 8)) + (c.blue());
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1300 return pixel;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1301 // funny no ? it looks like with Qt we can always use directly the rgb
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1302 // value (i hope i don't break colors again ;p)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1303 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1304
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1305 /*
87
014ba200db86 updated for version 7.0035
vimboss
parents: 75
diff changeset
1306 * Get current mouse coordinates in text window.
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1307 */
87
014ba200db86 updated for version 7.0035
vimboss
parents: 75
diff changeset
1308 void
014ba200db86 updated for version 7.0035
vimboss
parents: 75
diff changeset
1309 gui_mch_getmouse(int *x, int *y)//{{{
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1310 {
87
014ba200db86 updated for version 7.0035
vimboss
parents: 75
diff changeset
1311 *x = vmw->mapFromGlobal(QCursor::pos()).x();
014ba200db86 updated for version 7.0035
vimboss
parents: 75
diff changeset
1312 *y = vmw->mapFromGlobal(QCursor::pos()).y();
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1313 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1314
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1315 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1316 gui_mch_setmouse(int x, int y)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1317 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1318 QCursor::setPos(vmw->mapToGlobal(QPoint(x, y)));
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1319 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1320
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1321 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1322 #if QT_VERSION>=300
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1323 static int mshape_ids[] = {//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1324 Qt::ArrowCursor, /* arrow */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1325 Qt::BlankCursor, /* blank */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1326 Qt::IbeamCursor, /* beam */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1327 Qt::SizeVerCursor, /* updown */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1328 Qt::SplitHCursor, /* udsizing */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1329 Qt::SizeHorCursor, /* leftright */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1330 Qt::SizeHorCursor, /* lrsizing */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1331 Qt::WaitCursor, /* busy */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1332 Qt::ForbiddenCursor, /* no */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1333 Qt::CrossCursor, /* crosshair */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1334 Qt::PointingHandCursor, /* hand1 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1335 Qt::PointingHandCursor, /* hand2 */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1336 Qt::ArrowCursor, /* pencil */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1337 Qt::WhatsThisCursor, /* question */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1338 Qt::ArrowCursor, /* right-arrow */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1339 Qt::UpArrowCursor, /* up-arrow */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1340 Qt::ArrowCursor /* last one */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1341 };//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1342 #else
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1343 static int mshape_ids[] = {//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1344 ArrowCursor, /* arrow */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1345 BlankCursor, /* blank */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1346 IbeamCursor, /* beam */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1347 SizeVerCursor, /* updown */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1348 SplitHCursor, /* udsizing */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1349 SizeHorCursor, /* leftright */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1350 SizeHorCursor, /* lrsizing */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1351 WaitCursor, /* busy */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1352 ForbiddenCursor, /* no */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1353 CrossCursor, /* crosshair */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1354 PointingHandCursor, /* hand1 */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1355 PointingHandCursor, /* hand2 */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1356 ArrowCursor, /* pencil */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1357 ArrowCursor, /* question */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1358 ArrowCursor, /* right-arrow */
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1359 UpArrowCursor, /* up-arrow */
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1360 ArrowCursor /* last one */
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1361 };//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1362 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1363
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1364 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1365 mch_set_mouse_shape (int shape)//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1366 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1367 int id;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1368
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1369 if (shape == MSHAPE_HIDE || gui.pointer_hidden)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1370 #if QT_VERSION>=300
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1371 gui.w->setCursor(Qt::BlankCursor);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1372 #else
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1373 gui.w->setCursor(BlankCursor);
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1374 #endif
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1375 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1376 {
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1377 if (shape >= MSHAPE_NUMBERED)
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1378 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1379 id = shape - MSHAPE_NUMBERED;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1380 /* if (id >= GDK_NUM_GLYPHS)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1381 id = GDK_LEFT_PTR;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1382 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1383 id &= ~1;*/ /* they are always even (why?) */
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1384 id &= -1;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1385 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1386 else
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1387 id = mshape_ids[shape];
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1388
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1389 gui.w->setCursor(id);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1390 }
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1391 if (shape != MSHAPE_HIDE)
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1392 last_shape = shape;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1393 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1394 #endif
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1395
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1396 int
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1397 gui_mch_adjust_charsize ()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1398 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1399 QFont f(*(gui.current_font));
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1400 QFontMetrics fm(f);
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1401 gui.char_height = fm.height() + p_linespace;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1402 //gui.char_height = fm.ascent() + fm.descent() + p_linespace;
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1403 gui.char_ascent = fm.ascent() + p_linespace / 2;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1404
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1405 return OK;
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1406 }//}}}
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1407
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1408 void
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1409 gui_mch_set_foreground ()//{{{
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1410 {
42
c75153d791d0 updated for version 7.0026
vimboss
parents: 37
diff changeset
1411 KWin::setActiveWindow(vmw->winId());
11
4424b47a0797 updated for version 7.0003
vimboss
parents:
diff changeset
1412 }//}}}