vcl: convert MessageDialog to use VclReferences.
Change-Id: I24035c67c99ce431e94b39bd6d0d3b274fa55fa8
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 3dbde87..e937c81 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -24,6 +24,7 @@
#include <vcl/dllapi.h>
#include <vcl/syswin.hxx>
#include <vcl/timer.hxx>
#include <vcl/vclref.hxx>
// parameter to pass to the dialog constructor if really no parent is wanted
// whereas NULL chooses the default dialog parent
@@ -47,8 +48,8 @@ private:
bool mbInClose;
bool mbModalMode;
VclButtonBox* mpActionArea;
VclBox* mpContentArea;
VclReference<VclButtonBox> mpActionArea;
VclReference<VclBox> mpContentArea;
SAL_DLLPRIVATE void ImplInitDialogData();
SAL_DLLPRIVATE void ImplInitSettings();
@@ -74,8 +75,8 @@ protected:
protected:
friend class VclBuilder;
void set_action_area(VclButtonBox *pBox);
void set_content_area(VclBox *pBox);
void set_action_area(const VclReference<VclButtonBox> &xBox);
void set_content_area(const VclReference<VclBox> &xBox);
public:
explicit Dialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG );
@@ -88,8 +89,8 @@ public:
virtual void queue_resize(StateChangedType eReason = StateChangedType::LAYOUT) SAL_OVERRIDE;
virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
VclButtonBox* get_action_area() { return mpActionArea;}
VclBox* get_content_area() { return mpContentArea;}
VclButtonBox* get_action_area() { return mpActionArea.get(); }
VclBox* get_content_area() { return mpContentArea.get(); }
virtual bool Close() SAL_OVERRIDE;
@@ -121,6 +122,7 @@ public:
void GrabFocusToFirstControl();
};
typedef VclReference<Dialog> DialogRef;
// - ModelessDialog -
class VCL_DLLPUBLIC ModelessDialog : public Dialog
@@ -131,6 +133,7 @@ class VCL_DLLPUBLIC ModelessDialog : public Dialog
public:
explicit ModelessDialog( vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription );
};
typedef VclReference<ModelessDialog> ModelessDialogRef;
// - ModalDialog -
class VCL_DLLPUBLIC ModalDialog : public Dialog
@@ -150,6 +153,7 @@ private:
SAL_DLLPRIVATE ModalDialog (const ModalDialog &) SAL_DELETED_FUNCTION;
SAL_DLLPRIVATE ModalDialog & operator= (const ModalDialog &) SAL_DELETED_FUNCTION;
};
typedef VclReference<ModalDialog> ModalDialogRef;
#endif // INCLUDED_VCL_DIALOG_HXX
diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx
index 9f58876..f677172 100644
--- a/include/vcl/layout.hxx
+++ b/include/vcl/layout.hxx
@@ -17,6 +17,7 @@
#include <vcl/scrbar.hxx>
#include <vcl/vclmedit.hxx>
#include <vcl/window.hxx>
#include <vcl/vclref.hxx>
#include <boost/multi_array.hpp>
#include <set>
@@ -58,6 +59,7 @@ public:
private:
bool m_bLayoutDirty;
};
typedef VclReference<VclContainer> VclContainerRef;
class VCL_DLLPUBLIC VclBox : public VclContainer
{
@@ -109,6 +111,7 @@ protected:
virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const = 0;
};
typedef VclReference<VclBox> VclBoxRef;
class VCL_DLLPUBLIC VclVBox : public VclBox
{
@@ -156,6 +159,7 @@ protected:
return rWindow.get_expand() || rWindow.get_vexpand();
}
};
typedef VclReference<VclVBox> VclVBoxRef;
class VCL_DLLPUBLIC VclHBox : public VclBox
{
@@ -203,6 +207,7 @@ protected:
return rWindow.get_expand() || rWindow.get_hexpand();
}
};
typedef VclReference<VclHBox> VclHBoxRef;
enum VclButtonBoxStyle
{
@@ -248,6 +253,7 @@ private:
Requisition calculatePrimarySecondaryRequisitions() const;
Size addReqGroups(const VclButtonBox::Requisition &rReq) const;
};
typedef VclReference<VclButtonBox> VclButtonBoxRef;
class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox
{
@@ -295,6 +301,7 @@ protected:
return rWindow.get_expand() || rWindow.get_vexpand();
}
};
typedef VclReference<VclVButtonBox> VclVButtonBoxRef;
class VCL_DLLPUBLIC VclHButtonBox : public VclButtonBox
{
@@ -342,6 +349,7 @@ protected:
return rWindow.get_expand() || rWindow.get_hexpand();
}
};
typedef VclReference<VclHButtonBox> VclHButtonBoxRef;
class VCL_DLLPUBLIC VclGrid : public VclContainer
{
@@ -435,6 +443,7 @@ public:
}
virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
};
typedef VclReference<VclGrid> VclGridRef;
VCL_DLLPUBLIC void setGridAttach(vcl::Window &rWidget, sal_Int32 nLeft, sal_Int32 nTop,
sal_Int32 nWidth = 1, sal_Int32 nHeight = 1);
@@ -451,6 +460,7 @@ public:
virtual Size calculateRequisition() const SAL_OVERRIDE;
virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
};
typedef VclReference<VclBin> VclBinRef;
class VCL_DLLPUBLIC VclFrame : public VclBin
{
@@ -477,6 +487,7 @@ protected:
virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
virtual OUString getDefaultAccessibleName() const SAL_OVERRIDE;
};
typedef VclReference<VclFrame> VclFrameRef;
class VCL_DLLPUBLIC VclAlignment : public VclBin
{
@@ -507,6 +518,7 @@ private:
float m_fYAlign;
float m_fYScale;
};
typedef VclReference<VclAlignment> VclAlignmentRef;
class VCL_DLLPUBLIC VclExpander : public VclBin
{
@@ -551,6 +563,7 @@ private:
Link maExpandedHdl;
DECL_DLLPRIVATE_LINK(ClickHdl, DisclosureButton* pBtn);
};
typedef VclReference<VclExpander> VclExpanderRef;
class VCL_DLLPUBLIC VclScrolledWindow : public VclBin
{
@@ -578,6 +591,7 @@ private:
ScrollBarPtr m_pHScroll;
ScrollBarBox m_aScrollBarBox;
};
typedef VclReference<VclScrolledWindow> VclScrolledWindowRef;
class VCL_DLLPUBLIC VclViewport : public VclBin
{
@@ -589,6 +603,7 @@ public:
protected:
virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
};
typedef VclReference<VclViewport> VclViewportRef;
//Enforces that its children are always the same size as itself.
//Intercepts any Commands intended for its children.
@@ -633,6 +648,7 @@ public:
virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE;
};
typedef VclReference<VclEventBox> VclEventBoxRef;
enum VclSizeGroupMode
{
@@ -684,6 +700,7 @@ public:
}
bool set_property(const OString &rKey, const OString &rValue);
};
typedef VclReference<VclSizeGroup> VclSizeGroupRef;
enum VclButtonsType
{
@@ -708,13 +725,13 @@ class VCL_DLLPUBLIC MessageDialog : public Dialog
private:
VclButtonsType m_eButtonsType;
VclMessageType m_eMessageType;
VclBox *m_pOwnedContentArea;
VclButtonBox *m_pOwnedActionArea;
VclGrid* m_pGrid;
VclBoxRef m_pOwnedContentArea;
VclButtonBoxRef m_pOwnedActionArea;
VclGridRef m_pGrid;
FixedImage* m_pImage;
VclMultiLineEdit* m_pPrimaryMessage;
VclMultiLineEdit* m_pSecondaryMessage;
std::vector<PushButton*> m_aOwnedButtons;
std::vector<PushButtonPtr> m_aOwnedButtons;
std::map<const vcl::Window*, short> m_aResponses;
OUString m_sPrimaryString;
OUString m_sSecondaryString;
@@ -747,6 +764,7 @@ public:
static void SetMessagesWidths(vcl::Window *pParent, VclMultiLineEdit *pPrimaryMessage,
VclMultiLineEdit *pSecondaryMessage);
};
typedef VclReference<MessageDialog> MessageDialogRef;
VCL_DLLPUBLIC Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize);
diff --git a/include/vcl/vclref.hxx b/include/vcl/vclref.hxx
index ddbff3e..b9b7b53 100644
--- a/include/vcl/vclref.hxx
+++ b/include/vcl/vclref.hxx
@@ -50,7 +50,7 @@ public:
/** Copy constructor...
*/
inline VclReference (const VclReference<reference_type> & handle)
: m_rInnerRef (handle)
: m_rInnerRef (handle.m_rInnerRef)
{}
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 1e9f53a..51445a0 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -509,14 +509,14 @@ Dialog::Dialog(vcl::Window* pParent, WinBits nStyle)
ImplInit( pParent, nStyle );
}
void Dialog::set_action_area(VclButtonBox* pActionArea)
void Dialog::set_action_area(const VclButtonBoxRef &xBox)
{
mpActionArea = pActionArea;
mpActionArea = xBox;
}
void Dialog::set_content_area(VclBox* pContentArea)
void Dialog::set_content_area(const VclBoxRef &xBox)
{
mpContentArea = pContentArea;
mpContentArea = xBox;
}
void Dialog::settingOptimalLayoutSize(Window *pBox)
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index b0e27e7..f0264ce 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -1942,7 +1942,7 @@ void MessageDialog::create_owned_areas()
m_pOwnedContentArea = new VclVBox(this, false, 24);
set_content_area(m_pOwnedContentArea);
m_pOwnedContentArea->Show();
m_pOwnedActionArea = new VclHButtonBox(m_pOwnedContentArea);
m_pOwnedActionArea = new VclHButtonBox(m_pOwnedContentArea.get());
set_action_area(m_pOwnedActionArea);
m_pOwnedActionArea->Show();
}
@@ -1995,7 +1995,7 @@ MessageDialog::MessageDialog(vcl::Window* pParent, const OString& rID, const OUS
void MessageDialog::dispose()
{
for (size_t i = 0; i < m_aOwnedButtons.size(); ++i)
delete m_aOwnedButtons[i];
m_aOwnedButtons[i].disposeAndClear();
m_aOwnedButtons.clear();
delete m_pSecondaryMessage;
@@ -2007,14 +2007,9 @@ void MessageDialog::dispose()
delete m_pImage;
m_pImage = NULL;
delete m_pGrid;
m_pGrid = NULL;
delete m_pOwnedActionArea;
m_pOwnedActionArea = NULL;
delete m_pOwnedContentArea;
m_pOwnedContentArea = NULL;
m_pGrid.disposeAndClear();
m_pOwnedActionArea.disposeAndClear();
m_pOwnedContentArea.disposeAndClear();
Dialog::dispose();
}
@@ -2105,7 +2100,7 @@ short MessageDialog::Execute()
{
setDeferredProperties();
if (!m_pGrid)
if (!m_pGrid.get())
{
VclContainer *pContainer = get_content_area();
assert(pContainer);
@@ -2115,7 +2110,7 @@ short MessageDialog::Execute()
m_pGrid->set_column_spacing(12);
m_pGrid->set_row_spacing(GetTextHeight());
m_pImage = new FixedImage(m_pGrid, WB_CENTER | WB_VCENTER | WB_3DLOOK);
m_pImage = new FixedImage(m_pGrid.get(), WB_CENTER | WB_VCENTER | WB_3DLOOK);
switch (m_eMessageType)
{
case VCL_MESSAGE_INFO:
@@ -2140,7 +2135,7 @@ short MessageDialog::Execute()
bool bHasSecondaryText = !m_sSecondaryString.isEmpty();
m_pPrimaryMessage = new VclMultiLineEdit(m_pGrid, nWinStyle);
m_pPrimaryMessage = new VclMultiLineEdit(m_pGrid.get(), nWinStyle);
m_pPrimaryMessage->SetPaintTransparent(true);
m_pPrimaryMessage->EnableCursor(false);
@@ -2150,7 +2145,7 @@ short MessageDialog::Execute()
m_pPrimaryMessage->SetText(m_sPrimaryString);
m_pPrimaryMessage->Show(!m_sPrimaryString.isEmpty());
m_pSecondaryMessage = new VclMultiLineEdit(m_pGrid, nWinStyle);
m_pSecondaryMessage = new VclMultiLineEdit(m_pGrid.get(), nWinStyle);
m_pSecondaryMessage->SetPaintTransparent(true);
m_pSecondaryMessage->EnableCursor(false);
m_pSecondaryMessage->set_grid_left_attach(1);
@@ -2164,56 +2159,56 @@ short MessageDialog::Execute()
VclButtonBox *pButtonBox = get_action_area();
assert(pButtonBox);
PushButton *pBtn;
PushButtonPtr pBtn;
switch (m_eButtonsType)
{
case VCL_BUTTONS_NONE:
break;
case VCL_BUTTONS_OK:
pBtn = new OKButton(pButtonBox);
pBtn = PushButtonPtr(new OKButton(pButtonBox));
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_OK;
m_aResponses[pBtn.get()] = RET_OK;
break;
case VCL_BUTTONS_CLOSE:
pBtn = new CloseButton(pButtonBox);
pBtn = PushButtonPtr(new CloseButton(pButtonBox));
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_CLOSE;
m_aResponses[pBtn.get()] = RET_CLOSE;
break;
case VCL_BUTTONS_CANCEL:
pBtn = new CancelButton(pButtonBox);
pBtn = PushButtonPtr(new CancelButton(pButtonBox));
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_CANCEL;
m_aResponses[pBtn.get()] = RET_CANCEL;
break;
case VCL_BUTTONS_YES_NO:
pBtn = new PushButton(pButtonBox);
pBtn = PushButtonPtr(new PushButton(pButtonBox));
pBtn->SetText(Button::GetStandardText(StandardButtonType::Yes));
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_YES;
m_aResponses[pBtn.get()] = RET_YES;
pBtn = new PushButton(pButtonBox);
pBtn = PushButtonPtr(new PushButton(pButtonBox));
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->SetText(Button::GetStandardText(StandardButtonType::No));
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_NO;
m_aResponses[pBtn.get()] = RET_NO;
break;
case VCL_BUTTONS_OK_CANCEL:
pBtn = new OKButton(pButtonBox);
pBtn = PushButtonPtr(new OKButton(pButtonBox));
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_OK;
m_aResponses[pBtn.get()] = RET_OK;
pBtn = new CancelButton(pButtonBox);
pBtn = PushButtonPtr(new CancelButton(pButtonBox));
pBtn->SetStyle(pBtn->GetStyle() & WB_DEFBUTTON);
pBtn->Show();
m_aOwnedButtons.push_back(pBtn);
m_aResponses[pBtn] = RET_CANCEL;
m_aResponses[pBtn.get()] = RET_CANCEL;
break;
}
setButtonHandlers(pButtonBox);