Mercurial > octave
annotate libgui/graphics/EditControl.cc @ 21203:710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rename guard #ifdef names to use octave_ namespace prefix and file name.
Indent #ifdef blocks.
* Backend.cc, Backend.h, BaseControl.cc, BaseControl.h, ButtonControl.cc,
ButtonControl.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h,
Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc,
EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h,
GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, KeyMap.h,
ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h,
MenuContainer.h, MouseModeActionGroup.cc, MouseModeActionGroup.h, Object.cc,
Object.h, ObjectFactory.cc, ObjectFactory.h, ObjectProxy.cc, ObjectProxy.h,
Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h,
PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h,
QtHandlesUtils.cc, QtHandlesUtils.h, RadioButtonControl.cc,
RadioButtonControl.h, SliderControl.cc, SliderControl.h, TextControl.cc,
TextControl.h, TextEdit.cc, TextEdit.h, ToggleButtonControl.cc,
ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h,
ToolBarButton.cc, ToolBarButton.h, __init_qt__.cc, __init_qt__.h,
annotation-dialog.cc, annotation-dialog.h, gl-select.cc, gl-select.h,
color-picker.cc, color-picker.h, dialog.cc, documentation-dock-widget.cc,
documentation-dock-widget.h, files-dock-widget.cc, files-dock-widget.h,
find-files-dialog.cc, find-files-dialog.h, find-files-model.cc,
find-files-model.h, history-dock-widget.cc, history-dock-widget.h,
file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc,
file-editor.h, find-dialog.cc, find-dialog.h, octave-qscintilla.cc,
octave-txt-lexer.cc, main-window.cc, octave-cmd.cc, octave-dock-widget.cc,
octave-gui.cc, octave-interpreter.cc, octave-interpreter.h, octave-qt-link.cc,
octave-qt-link.h, parser.cc, webinfo.cc, resource-manager.cc,
resource-manager.h, settings-dialog.cc, settings-dialog.h, shortcut-manager.cc,
shortcut-manager.h, terminal-dock-widget.cc, terminal-dock-widget.h,
thread-manager.cc, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc,
workspace-view.cc:
Clean up naming and indentation of #ifdef blocks in libgui.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 06 Feb 2016 07:32:37 -0800 |
parents | aa36fb998a4d |
children | 40de9f8f23a6 |
rev | line source |
---|---|
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
1 /* |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
2 |
20003
f0e61a67ad9f
Update copyright year in Qt graphics code.
John W. Eaton <jwe@octave.org>
parents:
19967
diff
changeset
|
3 Copyright (C) 2011-2015 Michael Goffioul |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
4 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
5 This file is part of Octave. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
6 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
7 Octave is free software; you can redistribute it and/or modify it |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
8 under the terms of the GNU General Public License as published by the |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
9 Free Software Foundation; either version 3 of the License, or (at your |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
10 option) any later version. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
11 |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
15 for more details. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
16 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
17 You should have received a copy of the GNU General Public License |
18500
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
18 along with Octave; see the file COPYING. If not, see |
49877d3be064
update copyright notices for new QtHandles code
John W. Eaton <jwe@octave.org>
parents:
18498
diff
changeset
|
19 <http://www.gnu.org/licenses/>. |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
20 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
21 */ |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
22 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
23 #ifdef HAVE_CONFIG_H |
21203
710e700cdd7f
maint: Clean up naming and indentation of #ifdef blocks in libgui
Rik <rik@octave.org>
parents:
20181
diff
changeset
|
24 # include <config.h> |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 #endif |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #include <QLineEdit> |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include "Container.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 #include "EditControl.h" |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include "TextEdit.h" |
18505
fb96b7f55242
rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents:
18501
diff
changeset
|
32 #include "QtHandlesUtils.h" |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
37 EditControl* |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
38 EditControl::create (const graphics_object& go) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
39 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
40 Object* parent = Object::parentObject (go); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
41 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
42 if (parent) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
43 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
44 Container* container = parent->innerContainer (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
46 if (container) |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
47 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
48 uicontrol::properties& up = Utils::properties<uicontrol> (go); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
49 |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
50 if ((up.get_max () - up.get_min ()) > 1) |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
51 return new EditControl (go, new TextEdit (container)); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
52 else |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
53 return new EditControl (go, new QLineEdit (container)); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
54 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
55 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
57 return 0; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
59 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 EditControl::EditControl (const graphics_object& go, QLineEdit* edit) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
61 : BaseControl (go, edit), m_multiLine (false), m_textChanged (false) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
62 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
63 init (edit); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
64 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
66 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
67 EditControl::init (QLineEdit* edit, bool callBase) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
68 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
69 if (callBase) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 BaseControl::init (edit, callBase); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
71 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
72 m_multiLine = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
73 initCommon (edit); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
75 uicontrol::properties& up = properties<uicontrol> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
76 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
77 edit->setText (Utils::fromStdString (up.get_string_string ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
78 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
79 up.get_verticalalignment ())); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
81 connect (edit, SIGNAL (textEdited (const QString&)), |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
82 SLOT (textChanged (void))); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
83 connect (edit, SIGNAL (editingFinished (void)), |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
84 SLOT (editingFinished (void))); |
20011
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
85 connect (edit, SIGNAL (returnPressed (void)), |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
86 SLOT (returnPressed (void))); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
87 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
89 EditControl::EditControl (const graphics_object& go, TextEdit* edit) |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
90 : BaseControl (go, edit), m_multiLine (true), m_textChanged (false) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
92 init (edit); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
93 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
94 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
95 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
96 EditControl::init (TextEdit* edit, bool callBase) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
97 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
98 if (callBase) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 BaseControl::init (edit, callBase); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
100 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
101 m_multiLine = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 initCommon (edit); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
103 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
104 uicontrol::properties& up = properties<uicontrol> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
105 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
106 edit->setAcceptRichText (false); |
20037
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
107 edit->setPlainText (Utils::fromStringVector (up.get_string_vector()).join("\n")); |
19595
be7ac98fab43
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18505
diff
changeset
|
108 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
109 connect (edit, SIGNAL (textChanged (void)), |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
110 SLOT (textChanged (void))); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
111 connect (edit, SIGNAL (editingFinished (void)), |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
112 SLOT (editingFinished (void))); |
20011
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
113 connect (edit, SIGNAL (returnPressed (void)), |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
114 SLOT (returnPressed (void))); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
115 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
116 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
117 EditControl::~EditControl (void) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
119 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
121 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
122 EditControl::initCommon (QWidget*) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
123 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
124 m_textChanged = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
125 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
126 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
127 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
128 EditControl::update (int pId) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
129 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 bool handled = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
131 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
132 if (m_multiLine) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
133 handled = updateMultiLine (pId); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
134 else |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
135 handled = updateSingleLine (pId); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 if (! handled) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
138 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
139 switch (pId) |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
140 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
141 default: |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
142 BaseControl::update (pId); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
143 break; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
144 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
145 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
146 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
147 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
148 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
149 EditControl::updateSingleLine (int pId) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
150 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
151 uicontrol::properties& up = properties<uicontrol> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
152 QLineEdit* edit = qWidget<QLineEdit> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
153 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
154 switch (pId) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
155 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
156 case uicontrol::properties::ID_STRING: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
157 edit->setText (Utils::fromStdString (up.get_string_string ())); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
158 return true; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
159 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
160 case uicontrol::properties::ID_HORIZONTALALIGNMENT: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
161 case uicontrol::properties::ID_VERTICALALIGNMENT: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
162 edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
163 up.get_verticalalignment ())); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
164 return true; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
165 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
166 case uicontrol::properties::ID_MIN: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
167 case uicontrol::properties::ID_MAX: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
168 if ((up.get_max () - up.get_min ()) > 1) |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
169 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
170 QWidget* container = edit->parentWidget (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
171 |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
172 delete edit; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
173 init (new TextEdit (container), true); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
174 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
175 return true; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
176 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
177 default: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
178 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
179 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
180 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
181 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
182 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
183 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
184 bool |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
185 EditControl::updateMultiLine (int pId) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
186 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
187 uicontrol::properties& up = properties<uicontrol> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
188 TextEdit* edit = qWidget<TextEdit> (); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
189 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
190 switch (pId) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
191 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
192 case uicontrol::properties::ID_STRING: |
20037
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
193 edit->setPlainText (Utils::fromStringVector (up.get_string_vector()).join("\n")); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
194 return true; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
195 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
196 case uicontrol::properties::ID_MIN: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
197 case uicontrol::properties::ID_MAX: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
198 if ((up.get_max () - up.get_min ()) <= 1) |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
199 { |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
200 QWidget* container = edit->parentWidget (); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
201 |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
202 delete edit; |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
203 init (new QLineEdit (container), true); |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
204 } |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
205 return true; |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
206 |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
207 default: |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
208 break; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
209 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
210 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
211 return false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
212 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
213 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
214 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
215 EditControl::textChanged (void) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
216 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
217 m_textChanged = true; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
218 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
219 |
20181
aa36fb998a4d
maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents:
20049
diff
changeset
|
220 void |
20011
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
221 EditControl::returnPressed (void) |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
222 { |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
223 QString txt = (m_multiLine |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
224 ? qWidget<TextEdit> ()->toPlainText () |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
225 : qWidget<QLineEdit> ()->text ()); |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
226 |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
227 if (m_textChanged) |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
228 { |
20037
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
229 if (m_multiLine) |
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
230 gh_manager::post_set (m_handle, "string", Utils::toCellString(txt.split("\n")), false); |
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
231 else |
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
232 gh_manager::post_set (m_handle, "string", Utils::toStdString (txt), false); |
20011
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
233 |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
234 m_textChanged = false; |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
235 } |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
236 |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
237 if (txt.length () > 0) |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
238 gh_manager::post_callback (m_handle, "callback"); |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
239 } |
2535b9ffa2fc
Qt EditControl: do callback always on return pressed (Bug #44690)
John Donoghue
parents:
20003
diff
changeset
|
240 |
19967
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
241 void |
3cc0734283dc
style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents:
19625
diff
changeset
|
242 EditControl::editingFinished (void) |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
243 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
244 if (m_textChanged) |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
245 { |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
246 QString txt = (m_multiLine |
19621
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
247 ? qWidget<TextEdit> ()->toPlainText () |
af0399a5aae0
untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents:
19595
diff
changeset
|
248 : qWidget<QLineEdit> ()->text ()); |
20037
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
249 if (m_multiLine) |
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
250 gh_manager::post_set (m_handle, "string", Utils::toCellString(txt.split("\n")), false); |
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
251 else |
76c72314d905
QT Text/EditControl: support String cells (Bug 44749)
John Donoghue
parents:
20011
diff
changeset
|
252 gh_manager::post_set (m_handle, "string", Utils::toStdString (txt), false); |
18498
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
253 gh_manager::post_callback (m_handle, "callback"); |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
254 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
255 m_textChanged = false; |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
256 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
257 } |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
258 |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
259 }; // namespace QtHandles |
2e7cad6f180c
Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
260 |