summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-06-30 14:38:57 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-06-30 16:31:48 +0100
commiteb8c56127af9843f55eea649f210c6077c97ea49 (patch)
treee5792b51f3f371fa1506ba08c2a61e8fa11037e2 /fpicker
parentd48af86c9b745d750c97ba9b1c59ea936bcab0ae (diff)
rework resize into a custom widget
so that the order of resizing will happen in the right sequence to work correctly every time Change-Id: I1adffe276db3fb80eb34ca74c2ceb51a6ee28526
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/iodlg.cxx129
-rw-r--r--fpicker/source/office/iodlg.hxx3
-rw-r--r--fpicker/source/office/iodlgimp.hxx4
-rw-r--r--fpicker/uiconfig/ui/explorerfiledialog.ui6
4 files changed, 73 insertions, 69 deletions
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index fc1d24b6077f..babf443b4b77 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -412,7 +412,57 @@ SvtFileDialog::SvtFileDialog ( Window* _pParent, WinBits nBits )
Init_Impl( nBits );
}
+class CustomContainer : public Window
+{
+ SvtExpFileDlg_Impl* _pImp;
+ SvtFileView* _pFileView;
+ Splitter* _pSplitter;
+
+public:
+ CustomContainer(Window *pParent)
+ : Window(pParent)
+ , _pImp(NULL)
+ , _pFileView(NULL)
+ , _pSplitter(NULL)
+ {
+ }
+
+ void init(SvtExpFileDlg_Impl* pImp,
+ SvtFileView* pFileView,
+ Splitter* pSplitter)
+ {
+ _pImp = pImp;
+ _pFileView = pFileView;
+ _pSplitter = pSplitter;
+ }
+ virtual void Resize() SAL_OVERRIDE
+ {
+ Window::Resize();
+
+ if (!_pImp || !_pImp->_pPlaces)
+ return;
+
+ Size aSize = GetSizePixel();
+
+ Point aBoxPos(_pFileView->GetPosPixel());
+ Size aNewSize(aSize.Width() - aBoxPos.X(), aSize.Height());
+ _pFileView->SetSizePixel( aNewSize );
+
+ // Resize the Splitter to fit the height
+ Size splitterNewSize = _pSplitter->GetSizePixel( );
+ splitterNewSize.Height() = aSize.Height();
+ _pSplitter->SetSizePixel( splitterNewSize );
+ sal_Int32 nMinX = _pImp->_pPlaces->GetPosPixel( ).X( );
+ sal_Int32 nMaxX = _pFileView->GetPosPixel( ).X( ) + _pFileView->GetSizePixel( ).Width() - nMinX;
+ _pSplitter->SetDragRectPixel( Rectangle( Point( nMinX, 0 ), Size( nMaxX, aSize.Width() ) ) );
+
+ // Resize the places list box to fit the height of the FileView
+ Size placesNewSize(_pImp->_pPlaces->GetSizePixel());
+ placesNewSize.Height() = aSize.Height();
+ _pImp->_pPlaces->SetSizePixel( placesNewSize );
+ }
+};
SvtFileDialog::~SvtFileDialog()
{
@@ -451,6 +501,7 @@ SvtFileDialog::~SvtFileDialog()
delete _pImp;
delete _pFileView;
delete _pSplitter;
+ delete _pContainer;
delete _pPrevBmp;
delete _pUserControls;
}
@@ -496,7 +547,6 @@ void SvtFileDialog::Init_Impl
_pImp->_pBtnUp->Show();
_pImp->_nStyle = nStyle;
- _pImp->_a6Size = LogicToPixel( Size( 6, 6 ), MAP_APPFONT );
_pImp->_eMode = ( nStyle & WB_SAVEAS ) ? FILEDLG_MODE_SAVE : FILEDLG_MODE_OPEN;
_pImp->_eDlgType = FILEDLG_TYPE_FILEDLG;
@@ -534,12 +584,14 @@ void SvtFileDialog::Init_Impl
if ( ( nStyle & SFXWB_MULTISELECTION ) == SFXWB_MULTISELECTION )
_pImp->_bMultiSelection = true;
- Window *pContainer = get<Window>("container");
+ _pContainer = new CustomContainer(get<Window>("container"));
Size aSize(LogicToPixel(Size(270, 85), MAP_APPFONT));
- pContainer->set_height_request(aSize.Height());
- pContainer->set_width_request(aSize.Width());
- pContainer->SetSizePixel(aSize);
- _pFileView = new SvtFileView( pContainer, WB_BORDER,
+ _pContainer->set_height_request(aSize.Height());
+ _pContainer->set_width_request(aSize.Width());
+ _pContainer->set_hexpand(true);
+ _pContainer->set_vexpand(true);
+
+ _pFileView = new SvtFileView( _pContainer, WB_BORDER,
FILEDLG_TYPE_PATHDLG == _pImp->_eDlgType,
_pImp->_bMultiSelection );
_pFileView->Show();
@@ -547,7 +599,7 @@ void SvtFileDialog::Init_Impl
_pFileView->SetHelpId( HID_FILEDLG_STANDARD );
_pFileView->SetStyle( _pFileView->GetStyle() | WB_TABSTOP );
- _pSplitter = new Splitter( pContainer, WB_HSCROLL );
+ _pSplitter = new Splitter( _pContainer, WB_HSCROLL );
_pSplitter->SetBackground( Wallpaper( Application::GetSettings().GetStyleSettings().GetFaceColor() ));
_pSplitter->SetSplitHdl( LINK( this, SvtFileDialog, Split_Hdl ) );
@@ -658,11 +710,12 @@ void SvtFileDialog::Init_Impl
OUString( "/org.openoffice.Office.UI/FilePicker" )
);
+ _pContainer->init(_pImp, _pFileView, _pSplitter);
+ _pContainer->Show();
+
Resize();
}
-
-
IMPL_STATIC_LINK( SvtFileDialog, NewFolderHdl_Impl, PushButton*, EMPTYARG )
{
pThis->_pFileView->EndInplaceEditing( false );
@@ -2239,9 +2292,6 @@ void SvtFileDialog::InitSize()
if ( _pImp->_aIniKey.isEmpty() )
return;
- Size aDlgSize = GetResizeOutputSizePixel();
- SetMinOutputSizePixel( aDlgSize );
-
// initialize from config
SvtViewOptions aDlgOpt( E_DIALOG, _pImp->_aIniKey );
@@ -2378,6 +2428,7 @@ void SvtFileDialog::DataChanged( const DataChangedEvent& _rDCEvt )
ModalDialog::DataChanged( _rDCEvt );
}
+
void SvtFileDialog::Resize()
{
Dialog::Resize();
@@ -2385,56 +2436,6 @@ void SvtFileDialog::Resize()
if ( IsRollUp() )
return;
- Window *pContainer = get<Window>("container");
- long nContainerHeight = pContainer->GetSizePixel().Height();
-
- Size aDlgSize = GetResizeOutputSizePixel();
- Size aOldSize = _pImp->_aDlgSize;
- _pImp->_aDlgSize = aDlgSize;
- long nWinDeltaW = 0;
-
- if(_pPrevBmp)
- {
- nWinDeltaW = _pPrevWin->GetOutputSizePixel().Width();
- _pPrevBmp->SetSizePixel(_pPrevWin->GetOutputSizePixel());
- }
-
- Size aNewSize = _pFileView->GetSizePixel();
- Point aBoxPos( _pFileView->GetPosPixel() );
- long nDeltaY = aNewSize.Height();
- long nDeltaX = aNewSize.Width();
- aNewSize.Height() = nContainerHeight;
- aNewSize.Width() = aDlgSize.Width() - aBoxPos.X() - 2*_pImp->_a6Size.Width() - nWinDeltaW;
- if ( aOldSize.Height() )
- nDeltaY = _pImp->_aDlgSize.Height() - aOldSize.Height();
- else
- nDeltaY = aNewSize.Height() - nDeltaY;
- nDeltaX = aNewSize.Width() - nDeltaX;
-
- if ( nWinDeltaW )
- nWinDeltaW = nDeltaX * 2 / 3;
- aNewSize.Width() -= nWinDeltaW;
- nDeltaX -= nWinDeltaW;
-
- _pFileView->SetSizePixel( aNewSize );
-
- // Resize the Splitter to fit the height
- Size splitterNewSize = _pSplitter->GetSizePixel( );
- splitterNewSize.Height() = nContainerHeight;
- _pSplitter->SetSizePixel( splitterNewSize );
- sal_Int32 nMinX = _pImp->_pPlaces->GetPosPixel( ).X( );
- sal_Int32 nMaxX = _pFileView->GetPosPixel( ).X( ) + _pFileView->GetSizePixel( ).Width() - nMinX;
- _pSplitter->SetDragRectPixel( Rectangle( Point( nMinX, 0 ), Size( nMaxX, aDlgSize.Width() ) ) );
-
- // Resize the places list box to fit the height of the FileView
- Size placesNewSize(_pImp->_pPlaces->GetSizePixel());
- placesNewSize.Height() = nContainerHeight;
- _pImp->_pPlaces->SetSizePixel( placesNewSize );
-
- if ( !nDeltaY && !nDeltaX )
- // This resize was only called to show or hide the indicator.
- return;
-
if ( _pFileNotifier )
_pFileNotifier->notify( DIALOG_SIZE_CHANGED, 0 );
}
@@ -2669,9 +2670,7 @@ void SvtFileDialog::AddControls_Impl( )
_pImp->_pLbImageTemplates->Show();
}
- Window *pContainer;
- get(pContainer, "container");
- _pImp->_pPlaces = new PlacesListBox( pContainer, this, SVT_RESSTR(STR_PLACES_TITLE), WB_BORDER );
+ _pImp->_pPlaces = new PlacesListBox(_pContainer, this, SVT_RESSTR(STR_PLACES_TITLE), WB_BORDER);
Size aSize(LogicToPixel(Size(50, 85), MAP_APPFONT));
_pImp->_pPlaces->set_height_request(aSize.Height());
_pImp->_pPlaces->set_width_request(aSize.Width());
diff --git a/fpicker/source/office/iodlg.hxx b/fpicker/source/office/iodlg.hxx
index 58fd9195e970..498432146b94 100644
--- a/fpicker/source/office/iodlg.hxx
+++ b/fpicker/source/office/iodlg.hxx
@@ -80,6 +80,8 @@ class SvtFileDialogFilter_Impl;
class SvtExpFileDlg_Impl;
+class CustomContainer;
+
class SvtFileDialog : public ModalDialog, public ::svt::IFilePickerController
{
private:
@@ -93,6 +95,7 @@ private:
PushButton* _pPbPlay;
Window* _pPrevWin;
FixedBitmap* _pPrevBmp;
+ CustomContainer* _pContainer;
SvtFileView* _pFileView;
Splitter* _pSplitter;
::svt::IFilePickerListener* _pFileNotifier;
diff --git a/fpicker/source/office/iodlgimp.hxx b/fpicker/source/office/iodlgimp.hxx
index 25b90d172b55..9b5d5e29ca10 100644
--- a/fpicker/source/office/iodlgimp.hxx
+++ b/fpicker/source/office/iodlgimp.hxx
@@ -181,9 +181,7 @@ public:
// MultiSelection?
bool _bMultiSelection;
- // remember fixsizes for resize
- Size _a6Size;
- Size _aDlgSize;
+ // remember sizes
OUString _aIniKey;
bool _bFolderHasOpened;
diff --git a/fpicker/uiconfig/ui/explorerfiledialog.ui b/fpicker/uiconfig/ui/explorerfiledialog.ui
index 2a82568506b0..de955242b52a 100644
--- a/fpicker/uiconfig/ui/explorerfiledialog.ui
+++ b/fpicker/uiconfig/ui/explorerfiledialog.ui
@@ -121,11 +121,15 @@
</packing>
</child>
<child>
- <object class="GtkDrawingArea" id="container">
+ <object class="GtkBox" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
<property name="expand">True</property>