2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #include <svtools/editbrowsebox.hxx>
20 #include <vcl/svapp.hxx>
25 ComboBoxControl::ComboBoxControl(BrowserDataWin
* pParent
)
26 : ControlBase(pParent
, u
"svt/ui/combocontrol.ui"_ustr
, u
"ComboControl"_ustr
)
27 , m_xWidget(m_xBuilder
->weld_combo_box(u
"combobox"_ustr
))
29 InitControlBase(m_xWidget
.get());
30 m_xWidget
->set_entry_width_chars(1); // so a smaller than default width can be used
31 m_xWidget
->connect_changed(LINK(this, ComboBoxControl
, SelectHdl
));
32 m_xWidget
->connect_key_press(LINK(this, ControlBase
, KeyInputHdl
));
33 m_xWidget
->connect_key_release(LINK(this, ControlBase
, KeyReleaseHdl
));
34 m_xWidget
->connect_focus_in(LINK(this, ControlBase
, FocusInHdl
));
35 m_xWidget
->connect_focus_out(LINK(this, ControlBase
, FocusOutHdl
));
36 m_xWidget
->connect_mouse_press(LINK(this, ControlBase
, MousePressHdl
));
37 m_xWidget
->connect_mouse_release(LINK(this, ControlBase
, MouseReleaseHdl
));
38 m_xWidget
->connect_mouse_move(LINK(this, ControlBase
, MouseMoveHdl
));
41 void ComboBoxControl::SetPointFont(const vcl::Font
& rFont
)
43 m_xWidget
->set_entry_font(rFont
);
46 void ComboBoxControl::dispose()
49 ControlBase::dispose();
52 IMPL_LINK_NOARG(ComboBoxControl
, SelectHdl
, weld::ComboBox
&, void)
57 //= ComboBoxCellController
58 ComboBoxCellController::ComboBoxCellController(ComboBoxControl
* pWin
)
61 static_cast<ComboBoxControl
&>(GetWindow()).SetModifyHdl(LINK(this, ComboBoxCellController
, ModifyHdl
));
64 IMPL_LINK_NOARG(ComboBoxCellController
, ModifyHdl
, LinkParamNone
*, void)
69 bool ComboBoxCellController::MoveAllowed(const KeyEvent
& rEvt
) const
71 weld::ComboBox
& rBox
= GetComboBox();
72 switch (rEvt
.GetKeyCode().GetCode())
77 int nStartPos
, nEndPos
;
78 bool bNoSelection
= rBox
.get_entry_selection_bounds(nStartPos
, nEndPos
);
79 return bNoSelection
&& nEndPos
== rBox
.get_active_text().getLength();
84 int nStartPos
, nEndPos
;
85 bool bNoSelection
= rBox
.get_entry_selection_bounds(nStartPos
, nEndPos
);
86 return bNoSelection
&& nStartPos
== 0;
90 if (rBox
.get_popup_shown())
92 if (!rEvt
.GetKeyCode().IsShift() &&
93 rEvt
.GetKeyCode().IsMod1())
95 // drop down the list box
96 else if (rEvt
.GetKeyCode().IsMod2() && rEvt
.GetKeyCode().GetCode() == KEY_DOWN
)
102 if (rBox
.get_popup_shown())
110 bool ComboBoxCellController::IsValueChangedFromSaved() const
112 return GetComboBox().get_value_changed_from_saved();
115 void ComboBoxCellController::SaveValue()
117 GetComboBox().save_value();
121 ListBoxControl::ListBoxControl(BrowserDataWin
* pParent
)
122 : ControlBase(pParent
, u
"svt/ui/listcontrol.ui"_ustr
, u
"ListControl"_ustr
)
123 , m_xWidget(m_xBuilder
->weld_combo_box(u
"listbox"_ustr
))
125 InitControlBase(m_xWidget
.get());
126 m_xWidget
->set_size_request(42, -1); // so a later narrow size request can stick
127 m_xWidget
->connect_changed(LINK(this, ListBoxControl
, SelectHdl
));
128 m_xWidget
->connect_key_press(LINK(this, ControlBase
, KeyInputHdl
));
129 m_xWidget
->connect_key_release(LINK(this, ControlBase
, KeyReleaseHdl
));
130 m_xWidget
->connect_focus_in(LINK(this, ControlBase
, FocusInHdl
));
131 m_xWidget
->connect_focus_out(LINK(this, ControlBase
, FocusOutHdl
));
132 m_xWidget
->connect_mouse_press(LINK(this, ControlBase
, MousePressHdl
));
133 m_xWidget
->connect_mouse_release(LINK(this, ControlBase
, MouseReleaseHdl
));
134 m_xWidget
->connect_mouse_move(LINK(this, ControlBase
, MouseMoveHdl
));
137 void ListBoxControl::SetPointFont(const vcl::Font
& rFont
)
139 m_xWidget
->set_font(rFont
);
142 void ListBoxControl::dispose()
145 ControlBase::dispose();
148 IMPL_LINK_NOARG(ListBoxControl
, SelectHdl
, weld::ComboBox
&, void)
153 //= ListBoxCellController
154 ListBoxCellController::ListBoxCellController(ListBoxControl
* pWin
)
155 :CellController(pWin
)
157 static_cast<ListBoxControl
&>(GetWindow()).SetModifyHdl(LINK(this, ListBoxCellController
, ListBoxSelectHdl
));
160 bool ListBoxCellController::MoveAllowed(const KeyEvent
& rEvt
) const
162 const weld::ComboBox
& rBox
= GetListBox();
163 switch (rEvt
.GetKeyCode().GetCode())
167 if (!rEvt
.GetKeyCode().IsShift() &&
168 rEvt
.GetKeyCode().IsMod1())
170 // drop down the list box
172 if (rEvt
.GetKeyCode().IsMod2() && rEvt
.GetKeyCode().GetCode() == KEY_DOWN
)
177 if (rBox
.get_popup_shown())
185 bool ListBoxCellController::IsValueChangedFromSaved() const
187 return GetListBox().get_value_changed_from_saved();
190 void ListBoxCellController::SaveValue()
192 GetListBox().save_value();
195 IMPL_LINK_NOARG(ListBoxCellController
, ListBoxSelectHdl
, LinkParamNone
*, void)
201 CheckBoxControl::CheckBoxControl(BrowserDataWin
* pParent
)
202 : ControlBase(pParent
, u
"svt/ui/checkboxcontrol.ui"_ustr
, u
"CheckBoxControl"_ustr
)
203 , m_xBox(m_xBuilder
->weld_check_button(u
"checkbox"_ustr
))
205 m_aModeState
.bTriStateEnabled
= true;
206 InitControlBase(m_xBox
.get());
207 m_xBox
->connect_key_press(LINK(this, ControlBase
, KeyInputHdl
));
208 m_xBox
->connect_key_release(LINK(this, ControlBase
, KeyReleaseHdl
));
209 m_xBox
->connect_focus_in(LINK(this, ControlBase
, FocusInHdl
));
210 m_xBox
->connect_focus_out(LINK(this, ControlBase
, FocusOutHdl
));
211 m_xBox
->connect_mouse_press(LINK(this, ControlBase
, MousePressHdl
));
212 m_xBox
->connect_mouse_release(LINK(this, ControlBase
, MouseReleaseHdl
));
213 m_xBox
->connect_mouse_move(LINK(this, ControlBase
, MouseMoveHdl
));
214 m_xBox
->connect_toggled(LINK(this, CheckBoxControl
, OnToggle
));
217 void CheckBoxControl::SetPointFont(const vcl::Font
& /*rFont*/)
221 void CheckBoxControl::EnableTriState( bool bTriState
)
223 if (m_aModeState
.bTriStateEnabled
!= bTriState
)
225 m_aModeState
.bTriStateEnabled
= bTriState
;
227 if (!m_aModeState
.bTriStateEnabled
&& GetState() == TRISTATE_INDET
)
228 SetState(TRISTATE_FALSE
);
232 void CheckBoxControl::SetState(TriState eState
)
234 if (!m_aModeState
.bTriStateEnabled
&& (eState
== TRISTATE_INDET
))
235 eState
= TRISTATE_FALSE
;
236 m_aModeState
.eState
= eState
;
237 m_xBox
->set_state(eState
);
240 CheckBoxControl::~CheckBoxControl()
245 void CheckBoxControl::dispose()
248 ControlBase::dispose();
251 void CheckBoxControl::Clicked()
253 // if tristate is enabled, m_aModeState will take care of setting the
254 // next state in the sequence via TriStateEnabled::ButtonToggled
255 if (!m_aModeState
.bTriStateEnabled
)
256 m_xBox
->set_active(!m_xBox
->get_active());
260 IMPL_LINK_NOARG(CheckBoxControl
, OnToggle
, weld::Toggleable
&, void)
262 m_aModeState
.ButtonToggled(*m_xBox
);
263 m_aToggleLink
.Call(*m_xBox
);
267 //= CheckBoxCellController
268 CheckBoxCellController::CheckBoxCellController(CheckBoxControl
* pWin
)
269 : CellController(pWin
)
271 static_cast<CheckBoxControl
&>(GetWindow()).SetModifyHdl( LINK(this, CheckBoxCellController
, ModifyHdl
) );
274 void CheckBoxCellController::ActivatingMouseEvent(const BrowserMouseEvent
& rEvt
, bool /*bUp*/)
276 CheckBoxControl
& rControl
= static_cast<CheckBoxControl
&>(GetWindow());
277 rControl
.GrabFocus();
279 // we have to adjust the position of the event relative to the controller's window
280 Point aPos
= rEvt
.GetPosPixel() - rEvt
.GetRect().TopLeft();
282 Size aControlSize
= rControl
.GetSizePixel();
283 Size aBoxSize
= rControl
.GetBox().get_preferred_size();
284 tools::Rectangle
aHotRect(Point((aControlSize
.Width() - aBoxSize
.Width()) / 2,
285 (aControlSize
.Height() - aBoxSize
.Height()) / 2),
288 // we want the initial mouse event to act as if it was performed on the checkbox
289 if (aHotRect
.Contains(aPos
))
293 weld::CheckButton
& CheckBoxCellController::GetCheckBox() const
295 return static_cast<CheckBoxControl
&>(GetWindow()).GetBox();
298 bool CheckBoxCellController::IsValueChangedFromSaved() const
300 return GetCheckBox().get_state_changed_from_saved();
303 void CheckBoxCellController::SaveValue()
305 GetCheckBox().save_state();
308 IMPL_LINK_NOARG(CheckBoxCellController
, ModifyHdl
, LinkParamNone
*, void)
313 //= MultiLineEditImplementation
314 OUString
MultiLineEditImplementation::GetText(LineEnd eSeparator
) const
316 weld::TextView
& rEntry
= m_rEdit
.get_widget();
317 return convertLineEnd(rEntry
.get_text(), eSeparator
);
320 OUString
MultiLineEditImplementation::GetSelected(LineEnd eSeparator
) const
322 int nStartPos
, nEndPos
;
323 weld::TextView
& rEntry
= m_rEdit
.get_widget();
324 rEntry
.get_selection_bounds(nStartPos
, nEndPos
);
325 return convertLineEnd(rEntry
.get_text().copy(nStartPos
, nEndPos
- nStartPos
), eSeparator
);
328 IMPL_LINK_NOARG(MultiLineEditImplementation
, ModifyHdl
, weld::TextView
&, void)
333 EditCellController::EditCellController( IEditImplementation
* _pImplementation
)
334 :CellController( &_pImplementation
->GetControl() )
335 ,m_pEditImplementation( _pImplementation
)
336 ,m_bOwnImplementation( false )
338 m_pEditImplementation
->SetModifyHdl( LINK(this, EditCellController
, ModifyHdl
) );
341 IMPL_LINK_NOARG(EntryImplementation
, ModifyHdl
, weld::Entry
&, void)
346 ControlBase::ControlBase(BrowserDataWin
* pParent
, const OUString
& rUIXMLDescription
, const OUString
& rID
)
347 : InterimItemWindow(pParent
, rUIXMLDescription
, rID
)
351 void ControlBase::SetEditableReadOnly(bool /*bReadOnly*/)
353 // expected to be overridden for Entry, TextView or the editable entry part of a ComboBox
356 EditControlBase::EditControlBase(BrowserDataWin
* pParent
)
357 : ControlBase(pParent
, u
"svt/ui/thineditcontrol.ui"_ustr
, u
"EditControl"_ustr
) // *thin*editcontrol has no frame/border
358 , m_pEntry(nullptr) // inheritors are expected to call InitEditControlBase
362 void EditControlBase::InitEditControlBase(weld::Entry
* pEntry
)
364 InitControlBase(pEntry
);
367 m_pEntry
->set_width_chars(1); // so a smaller than default width can be used
368 connect_focus_in(LINK(this, ControlBase
, FocusInHdl
)); // need to chain with pattern handler
369 connect_focus_out(LINK(this, ControlBase
, FocusOutHdl
)); // need to chain with pattern handler
370 connect_key_press(LINK(this, ControlBase
, KeyInputHdl
)); // need to chain with pattern handler
371 m_pEntry
->connect_key_release(LINK(this, ControlBase
, KeyReleaseHdl
));
372 m_pEntry
->connect_mouse_press(LINK(this, ControlBase
, MousePressHdl
));
373 m_pEntry
->connect_mouse_release(LINK(this, ControlBase
, MouseReleaseHdl
));
374 m_pEntry
->connect_mouse_move(LINK(this, ControlBase
, MouseMoveHdl
));
377 bool ControlBase::ProcessKey(const KeyEvent
& rKEvt
)
379 return static_cast<BrowserDataWin
*>(GetParent())->GetParent()->ProcessKey(rKEvt
);
382 IMPL_LINK(ControlBase
, KeyInputHdl
, const KeyEvent
&, rKEvt
, bool)
384 m_aKeyInputHdl
.Call(rKEvt
);
385 return ProcessKey(rKEvt
);
388 IMPL_LINK(ControlBase
, KeyReleaseHdl
, const KeyEvent
&, rKEvt
, bool)
390 m_aKeyReleaseHdl
.Call(rKEvt
);
394 IMPL_LINK_NOARG(ControlBase
, FocusInHdl
, weld::Widget
&, void)
396 m_aFocusInHdl
.Call(nullptr);
397 static_cast<BrowserDataWin
*>(GetParent())->GetParent()->ChildFocusIn();
400 IMPL_LINK_NOARG(ControlBase
, FocusOutHdl
, weld::Widget
&, void)
402 m_aFocusOutHdl
.Call(nullptr);
403 static_cast<BrowserDataWin
*>(GetParent())->GetParent()->ChildFocusOut();
406 IMPL_LINK(ControlBase
, MousePressHdl
, const MouseEvent
&, rEvent
, bool)
408 m_aMousePressHdl
.Call(rEvent
);
412 IMPL_LINK(ControlBase
, MouseReleaseHdl
, const MouseEvent
&, rEvent
, bool)
414 m_aMouseReleaseHdl
.Call(rEvent
);
418 IMPL_LINK(ControlBase
, MouseMoveHdl
, const MouseEvent
&, rEvent
, bool)
420 m_aMouseMoveHdl
.Call(rEvent
);
424 void EditControlBase::dispose()
427 ControlBase::dispose();
430 EditControl::EditControl(BrowserDataWin
* pParent
)
431 : EditControlBase(pParent
)
432 , m_xWidget(m_xBuilder
->weld_entry(u
"entry"_ustr
))
434 InitEditControlBase(m_xWidget
.get());
437 void EditControl::dispose()
440 EditControlBase::dispose();
443 FormattedControlBase::FormattedControlBase(BrowserDataWin
* pParent
, bool bSpinVariant
)
444 : EditControlBase(pParent
)
445 , m_bSpinVariant(bSpinVariant
)
446 , m_xEntry(m_xBuilder
->weld_entry(u
"entry"_ustr
))
447 , m_xSpinButton(m_xBuilder
->weld_formatted_spin_button(u
"spinbutton"_ustr
))
451 void FormattedControlBase::InitFormattedControlBase()
453 InitEditControlBase(m_bSpinVariant
? m_xSpinButton
.get() : m_xEntry
.get());
456 void FormattedControlBase::connect_changed(const Link
<weld::Entry
&, void>& rLink
)
458 get_formatter().connect_changed(rLink
);
461 void FormattedControlBase::connect_focus_in(const Link
<weld::Widget
&, void>& rLink
)
463 get_widget().connect_focus_in(rLink
);
466 void FormattedControlBase::connect_focus_out(const Link
<weld::Widget
&, void>& rLink
)
468 get_formatter().connect_focus_out(rLink
);
471 void FormattedControlBase::connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
473 get_widget().connect_key_press(rLink
);
476 weld::EntryFormatter
& FormattedControlBase::get_formatter()
478 return *m_xEntryFormatter
;
481 void FormattedControlBase::dispose()
483 m_xEntryFormatter
.reset();
484 m_xSpinButton
.reset();
486 EditControlBase::dispose();
489 FormattedControl::FormattedControl(BrowserDataWin
* pParent
, bool bSpinVariant
)
490 : FormattedControlBase(pParent
, bSpinVariant
)
493 m_xEntryFormatter
.reset(new weld::EntryFormatter(*m_xSpinButton
));
495 m_xEntryFormatter
.reset(new weld::EntryFormatter(*m_xEntry
));
496 InitFormattedControlBase();
499 DoubleNumericControl::DoubleNumericControl(BrowserDataWin
* pParent
, bool bSpinVariant
)
500 : FormattedControlBase(pParent
, bSpinVariant
)
503 m_xEntryFormatter
.reset(new weld::DoubleNumericFormatter(*m_xSpinButton
));
505 m_xEntryFormatter
.reset(new weld::DoubleNumericFormatter(*m_xEntry
));
506 InitFormattedControlBase();
509 LongCurrencyControl::LongCurrencyControl(BrowserDataWin
* pParent
, bool bSpinVariant
)
510 : FormattedControlBase(pParent
, bSpinVariant
)
513 m_xEntryFormatter
.reset(new weld::LongCurrencyFormatter(*m_xSpinButton
));
515 m_xEntryFormatter
.reset(new weld::LongCurrencyFormatter(*m_xEntry
));
516 InitFormattedControlBase();
519 TimeControl::TimeControl(BrowserDataWin
* pParent
, bool bSpinVariant
)
520 : FormattedControlBase(pParent
, bSpinVariant
)
523 m_xEntryFormatter
.reset(new weld::TimeFormatter(*m_xSpinButton
));
525 m_xEntryFormatter
.reset(new weld::TimeFormatter(*m_xEntry
));
526 InitFormattedControlBase();
529 DateControl::DateControl(BrowserDataWin
* pParent
, bool bDropDown
)
530 : FormattedControlBase(pParent
, false)
531 , m_xMenuButton(m_xBuilder
->weld_menu_button(u
"button"_ustr
))
532 , m_xCalendarBuilder(Application::CreateBuilder(m_xMenuButton
.get(), u
"svt/ui/datewindow.ui"_ustr
))
533 , m_xTopLevel(m_xCalendarBuilder
->weld_widget(u
"date_popup_window"_ustr
))
534 , m_xCalendar(m_xCalendarBuilder
->weld_calendar(u
"date_picker"_ustr
))
535 , m_xExtras(m_xCalendarBuilder
->weld_widget(u
"extras"_ustr
))
536 , m_xTodayBtn(m_xCalendarBuilder
->weld_button(u
"today"_ustr
))
537 , m_xNoneBtn(m_xCalendarBuilder
->weld_button(u
"none"_ustr
))
539 m_xEntryFormatter
.reset(new weld::DateFormatter(*m_xEntry
));
540 InitFormattedControlBase();
542 m_xMenuButton
->set_popover(m_xTopLevel
.get());
543 m_xMenuButton
->set_visible(bDropDown
);
544 m_xMenuButton
->connect_toggled(LINK(this, DateControl
, ToggleHdl
));
548 m_xTodayBtn
->connect_clicked(LINK(this, DateControl
, ImplClickHdl
));
549 m_xNoneBtn
->connect_clicked(LINK(this, DateControl
, ImplClickHdl
));
551 m_xCalendar
->connect_activated(LINK(this, DateControl
, ActivateHdl
));
554 IMPL_LINK(DateControl
, ImplClickHdl
, weld::Button
&, rBtn
, void)
556 m_xMenuButton
->set_active(false);
557 get_widget().grab_focus();
559 if (&rBtn
== m_xTodayBtn
.get())
561 Date
aToday(Date::SYSTEM
);
564 else if (&rBtn
== m_xNoneBtn
.get())
566 get_widget().set_text(OUString());
570 IMPL_LINK(DateControl
, ToggleHdl
, weld::Toggleable
&, rButton
, void)
572 if (rButton
.get_active())
573 m_xCalendar
->set_date(static_cast<weld::DateFormatter
&>(get_formatter()).GetDate());
576 IMPL_LINK_NOARG(DateControl
, ActivateHdl
, weld::Calendar
&, void)
578 if (m_xMenuButton
->get_active())
579 m_xMenuButton
->set_active(false);
580 static_cast<weld::DateFormatter
&>(get_formatter()).SetDate(m_xCalendar
->get_date());
583 void DateControl::SetDate(const Date
& rDate
)
585 static_cast<weld::DateFormatter
&>(get_formatter()).SetDate(rDate
);
586 m_xCalendar
->set_date(rDate
);
589 void DateControl::SetEditableReadOnly(bool bReadOnly
)
591 FormattedControlBase::SetEditableReadOnly(bReadOnly
);
592 m_xMenuButton
->set_sensitive(!bReadOnly
);
595 void DateControl::dispose()
602 m_xCalendarBuilder
.reset();
603 m_xMenuButton
.reset();
604 FormattedControlBase::dispose();
607 PatternControl::PatternControl(BrowserDataWin
* pParent
)
608 : EditControlBase(pParent
)
609 , m_xWidget(m_xBuilder
->weld_entry(u
"entry"_ustr
))
611 m_xEntryFormatter
.reset(new weld::PatternFormatter(*m_xWidget
));
612 InitEditControlBase(m_xWidget
.get());
615 void PatternControl::connect_changed(const Link
<weld::Entry
&, void>& rLink
)
617 m_xEntryFormatter
->connect_changed(rLink
);
620 void PatternControl::connect_focus_in(const Link
<weld::Widget
&, void>& rLink
)
622 m_xEntryFormatter
->connect_focus_in(rLink
);
625 void PatternControl::connect_focus_out(const Link
<weld::Widget
&, void>& rLink
)
627 m_xEntryFormatter
->connect_focus_out(rLink
);
630 void PatternControl::connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
632 m_xEntryFormatter
->connect_key_press(rLink
);
635 void PatternControl::dispose()
637 m_xEntryFormatter
.reset();
639 EditControlBase::dispose();
642 EditCellController::EditCellController(EditControlBase
* pEdit
)
643 : CellController(pEdit
)
644 , m_pEditImplementation(new EntryImplementation(*pEdit
))
645 , m_bOwnImplementation(true)
647 m_pEditImplementation
->SetModifyHdl( LINK(this, EditCellController
, ModifyHdl
) );
650 EditCellController::~EditCellController( )
652 if ( m_bOwnImplementation
)
653 delete m_pEditImplementation
;
656 void EditCellController::SaveValue()
658 m_pEditImplementation
->SaveValue();
661 bool EditCellController::MoveAllowed(const KeyEvent
& rEvt
) const
664 switch (rEvt
.GetKeyCode().GetCode())
669 Selection aSel
= m_pEditImplementation
->GetSelection();
670 bResult
= !aSel
&& aSel
.Max() == m_pEditImplementation
->GetText( LINEEND_LF
).getLength();
676 Selection aSel
= m_pEditImplementation
->GetSelection();
677 bResult
= !aSel
&& aSel
.Min() == 0;
682 bResult
= !m_pEditImplementation
->CanDown();
687 bResult
= !m_pEditImplementation
->CanUp();
696 bool EditCellController::IsValueChangedFromSaved() const
698 return m_pEditImplementation
->IsValueChangedFromSaved();
701 IMPL_LINK_NOARG(EditCellController
, ModifyHdl
, LinkParamNone
*, void)
706 //= FormattedFieldCellController
707 FormattedFieldCellController::FormattedFieldCellController( FormattedControlBase
* _pFormatted
)
708 : EditCellController(_pFormatted
)
712 void FormattedFieldCellController::CommitModifications()
714 static_cast<FormattedControl
&>(GetWindow()).get_formatter().Commit();
717 MultiLineTextCell::MultiLineTextCell(BrowserDataWin
* pParent
)
718 : ControlBase(pParent
, u
"svt/ui/textviewcontrol.ui"_ustr
, u
"TextViewControl"_ustr
)
719 , m_xWidget(m_xBuilder
->weld_text_view(u
"textview"_ustr
))
721 InitControlBase(m_xWidget
.get());
722 m_xWidget
->connect_key_press(LINK(this, ControlBase
, KeyInputHdl
));
723 m_xWidget
->connect_key_release(LINK(this, ControlBase
, KeyReleaseHdl
));
724 m_xWidget
->connect_focus_in(LINK(this, ControlBase
, FocusInHdl
));
725 m_xWidget
->connect_focus_out(LINK(this, ControlBase
, FocusOutHdl
));
726 m_xWidget
->connect_mouse_press(LINK(this, ControlBase
, MousePressHdl
));
727 m_xWidget
->connect_mouse_release(LINK(this, ControlBase
, MouseReleaseHdl
));
728 m_xWidget
->connect_mouse_move(LINK(this, ControlBase
, MouseMoveHdl
));
729 // so any the natural size doesn't have an effect
730 m_xWidget
->set_size_request(1, 1);
733 void MultiLineTextCell::GetFocus()
736 m_xWidget
->select_region(-1, 0);
737 ControlBase::GetFocus();
740 void MultiLineTextCell::dispose()
743 ControlBase::dispose();
746 bool MultiLineTextCell::ProcessKey(const KeyEvent
& rKEvt
)
748 bool bSendToDataWindow
= true;
750 sal_uInt16 nCode
= rKEvt
.GetKeyCode().GetCode();
751 bool bShift
= rKEvt
.GetKeyCode().IsShift();
752 bool bCtrl
= rKEvt
.GetKeyCode().IsMod1();
753 bool bAlt
= rKEvt
.GetKeyCode().IsMod2();
755 if (!bAlt
&& !bCtrl
&& !bShift
)
760 bSendToDataWindow
= !m_xWidget
->can_move_cursor_with_down();
763 bSendToDataWindow
= !m_xWidget
->can_move_cursor_with_up();
768 if (bSendToDataWindow
)
769 return ControlBase::ProcessKey(rKEvt
);
774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */