comparison libgui/graphics/BaseControl.cc @ 19655:af0399a5aae0 gui-release

untabify QtHandles source files
author John W. Eaton <jwe@octave.org>
date Fri, 23 Jan 2015 16:24:46 -0500
parents 709f3a77685d
children 6b2d7a5dc62a
comparison
equal deleted inserted replaced
19654:a1d172bfcb2f 19655:af0399a5aae0
43 if (props.style_is ("edit") 43 if (props.style_is ("edit")
44 || props.style_is ("listbox") 44 || props.style_is ("listbox")
45 || props.style_is ("popupmenu")) 45 || props.style_is ("popupmenu"))
46 { 46 {
47 p.setColor (QPalette::Base, 47 p.setColor (QPalette::Base,
48 Utils::fromRgb (props.get_backgroundcolor_rgb ())); 48 Utils::fromRgb (props.get_backgroundcolor_rgb ()));
49 p.setColor (QPalette::Text, 49 p.setColor (QPalette::Text,
50 Utils::fromRgb (props.get_foregroundcolor_rgb ())); 50 Utils::fromRgb (props.get_foregroundcolor_rgb ()));
51 } 51 }
52 else if (props.style_is ("pushbutton") 52 else if (props.style_is ("pushbutton")
53 || props.style_is ("togglebutton")) 53 || props.style_is ("togglebutton"))
54 { 54 {
55 p.setColor (QPalette::Button, 55 p.setColor (QPalette::Button,
56 Utils::fromRgb (props.get_backgroundcolor_rgb ())); 56 Utils::fromRgb (props.get_backgroundcolor_rgb ()));
57 p.setColor (QPalette::ButtonText, 57 p.setColor (QPalette::ButtonText,
58 Utils::fromRgb (props.get_foregroundcolor_rgb ())); 58 Utils::fromRgb (props.get_foregroundcolor_rgb ()));
59 } 59 }
60 else 60 else
61 { 61 {
62 p.setColor (QPalette::Window, 62 p.setColor (QPalette::Window,
63 Utils::fromRgb (props.get_backgroundcolor_rgb ())); 63 Utils::fromRgb (props.get_backgroundcolor_rgb ()));
64 p.setColor (QPalette::WindowText, 64 p.setColor (QPalette::WindowText,
65 Utils::fromRgb (props.get_foregroundcolor_rgb ())); 65 Utils::fromRgb (props.get_foregroundcolor_rgb ()));
66 } 66 }
67 67
68 w->setPalette (p); 68 w->setPalette (p);
69 } 69 }
70 70
81 81
82 uicontrol::properties& up = properties<uicontrol> (); 82 uicontrol::properties& up = properties<uicontrol> ();
83 83
84 Matrix bb = up.get_boundingbox (false); 84 Matrix bb = up.get_boundingbox (false);
85 w->setGeometry (xround (bb(0)), xround (bb(1)), 85 w->setGeometry (xround (bb(0)), xround (bb(1)),
86 xround (bb(2)), xround (bb(3))); 86 xround (bb(2)), xround (bb(3)));
87 w->setFont (Utils::computeFont<uicontrol> (up, bb(3))); 87 w->setFont (Utils::computeFont<uicontrol> (up, bb(3)));
88 updatePalette (up, w); 88 updatePalette (up, w);
89 w->setEnabled (up.enable_is ("on")); 89 w->setEnabled (up.enable_is ("on"));
90 w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); 90 w->setToolTip (Utils::fromStdString (up.get_tooltipstring ()));
91 w->setVisible (up.is_visible ()); 91 w->setVisible (up.is_visible ());
106 QWidget* w = qWidget<QWidget> (); 106 QWidget* w = qWidget<QWidget> ();
107 107
108 switch (pId) 108 switch (pId)
109 { 109 {
110 case uicontrol::properties::ID_POSITION: 110 case uicontrol::properties::ID_POSITION:
111 { 111 {
112 Matrix bb = up.get_boundingbox (false); 112 Matrix bb = up.get_boundingbox (false);
113 w->setGeometry (xround (bb(0)), xround (bb(1)), 113 w->setGeometry (xround (bb(0)), xround (bb(1)),
114 xround (bb(2)), xround (bb(3))); 114 xround (bb(2)), xround (bb(3)));
115 } 115 }
116 break; 116 break;
117 case uicontrol::properties::ID_FONTNAME: 117 case uicontrol::properties::ID_FONTNAME:
118 case uicontrol::properties::ID_FONTSIZE: 118 case uicontrol::properties::ID_FONTSIZE:
119 case uicontrol::properties::ID_FONTWEIGHT: 119 case uicontrol::properties::ID_FONTWEIGHT:
120 case uicontrol::properties::ID_FONTANGLE: 120 case uicontrol::properties::ID_FONTANGLE:
151 { 151 {
152 switch (ev->type ()) 152 switch (ev->type ())
153 { 153 {
154 case QEvent::Resize: 154 case QEvent::Resize:
155 if (m_normalizedFont) 155 if (m_normalizedFont)
156 { 156 {
157 gh_manager::auto_lock lock; 157 gh_manager::auto_lock lock;
158 158
159 qWidget<QWidget> ()->setFont (Utils::computeFont<uicontrol> 159 qWidget<QWidget> ()->setFont (Utils::computeFont<uicontrol>
160 (properties<uicontrol> ())); 160 (properties<uicontrol> ()));
161 } 161 }
162 break; 162 break;
163 case QEvent::MouseButtonPress: 163 case QEvent::MouseButtonPress:
164 { 164 {
165 gh_manager::auto_lock lock; 165 gh_manager::auto_lock lock;
166 166
167 QMouseEvent* m = dynamic_cast<QMouseEvent*> (ev); 167 QMouseEvent* m = dynamic_cast<QMouseEvent*> (ev);
168 graphics_object go = object (); 168 graphics_object go = object ();
169 uicontrol::properties& up = Utils::properties<uicontrol> (go); 169 uicontrol::properties& up = Utils::properties<uicontrol> (go);
170 graphics_object fig = go.get_ancestor ("figure"); 170 graphics_object fig = go.get_ancestor ("figure");
171 171
172 if (m->button () != Qt::LeftButton 172 if (m->button () != Qt::LeftButton
173 || ! up.enable_is ("on")) 173 || ! up.enable_is ("on"))
174 { 174 {
175 gh_manager::post_set (fig.get_handle (), "selectiontype", 175 gh_manager::post_set (fig.get_handle (), "selectiontype",
176 Utils::figureSelectionType (m), false); 176 Utils::figureSelectionType (m), false);
177 gh_manager::post_set (fig.get_handle (), "currentpoint", 177 gh_manager::post_set (fig.get_handle (), "currentpoint",
178 Utils::figureCurrentPoint (fig, m), 178 Utils::figureCurrentPoint (fig, m),
179 false); 179 false);
180 gh_manager::post_callback (fig.get_handle (), 180 gh_manager::post_callback (fig.get_handle (),
181 "windowbuttondownfcn"); 181 "windowbuttondownfcn");
182 gh_manager::post_callback (m_handle, "buttondownfcn"); 182 gh_manager::post_callback (m_handle, "buttondownfcn");
183 183
184 if (m->button () == Qt::RightButton) 184 if (m->button () == Qt::RightButton)
185 ContextMenu::executeAt (up, m->globalPos ()); 185 ContextMenu::executeAt (up, m->globalPos ());
186 } 186 }
187 else 187 else
188 { 188 {
189 if (up.style_is ("listbox")) 189 if (up.style_is ("listbox"))
190 gh_manager::post_set (fig.get_handle (), "selectiontype", 190 gh_manager::post_set (fig.get_handle (), "selectiontype",
191 Utils::figureSelectionType (m), false); 191 Utils::figureSelectionType (m), false);
192 else 192 else
193 gh_manager::post_set (fig.get_handle (), "selectiontype", 193 gh_manager::post_set (fig.get_handle (), "selectiontype",
194 octave_value ("normal"), false); 194 octave_value ("normal"), false);
195 } 195 }
196 } 196 }
197 break; 197 break;
198 case QEvent::MouseMove: 198 case QEvent::MouseMove:
199 if (qWidget<QWidget> ()->hasMouseTracking ()) 199 if (qWidget<QWidget> ()->hasMouseTracking ())
200 { 200 {
201 gh_manager::auto_lock lock; 201 gh_manager::auto_lock lock;
202 202
203 QMouseEvent* m = dynamic_cast<QMouseEvent*> (ev); 203 QMouseEvent* m = dynamic_cast<QMouseEvent*> (ev);
204 graphics_object go = object (); 204 graphics_object go = object ();
205 graphics_object fig = go.get_ancestor ("figure"); 205 graphics_object fig = go.get_ancestor ("figure");
206 206
207 gh_manager::post_set (fig.get_handle (), "currentpoint", 207 gh_manager::post_set (fig.get_handle (), "currentpoint",
208 Utils::figureCurrentPoint (fig, m), false); 208 Utils::figureCurrentPoint (fig, m), false);
209 gh_manager::post_callback (fig.get_handle (), "windowbuttonmotionfcn"); 209 gh_manager::post_callback (fig.get_handle (), "windowbuttonmotionfcn");
210 } 210 }