[Libreoffice-commits] .: Branch 'feature/template-dialog' - 2 commits - sfx2/AllLangResTarget_sfx2.mk sfx2/source
Rafael Dominguez
rdominguez at kemper.freedesktop.org
Wed Jul 4 10:06:39 PDT 2012
sfx2/AllLangResTarget_sfx2.mk | 1
sfx2/source/dialog/inputdlg.cxx | 68 +++++++++++++++++++++++++++-------------
sfx2/source/dialog/inputdlg.hrc | 6 +++
sfx2/source/dialog/inputdlg.src | 38 ++++++++++++++++++++++
sfx2/source/inc/inputdlg.hxx | 6 +++
5 files changed, 98 insertions(+), 21 deletions(-)
New commits:
commit cca67621756705365365eb904dff4171bfb5020d
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 4 12:35:45 2012 -0430
Connect button click handlers and end dialog with the desired result.
Change-Id: Ib87bd61c1cc7da906304c8ca43cd38d9a7bb1fcf
diff --git a/sfx2/source/dialog/inputdlg.cxx b/sfx2/source/dialog/inputdlg.cxx
index 74405c8..c1bd505 100644
--- a/sfx2/source/dialog/inputdlg.cxx
+++ b/sfx2/source/dialog/inputdlg.cxx
@@ -55,6 +55,9 @@ InputDialog::InputDialog (const rtl::OUString &rLabelText, Window *pParent)
aBtnPos.setX(aBtnPos.getX() - aBtnSize.getWidth() - LABEL_TEXT_SPACE);
mpOK->SetPosPixel(aBtnPos);
+
+ mpOK->SetClickHdl(LINK(this,InputDialog,ClickHdl));
+ mpCancel->SetClickHdl(LINK(this,InputDialog,ClickHdl));
}
InputDialog::~InputDialog()
@@ -70,6 +73,12 @@ rtl::OUString InputDialog::getEntryText () const
return mpEntry->GetText();
}
+IMPL_LINK(InputDialog,ClickHdl,PushButton*, pButton)
+{
+ EndDialog(pButton == mpOK ? true : false);
+ return 0;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/inc/inputdlg.hxx b/sfx2/source/inc/inputdlg.hxx
index 0df999d..1dce2fb 100644
--- a/sfx2/source/inc/inputdlg.hxx
+++ b/sfx2/source/inc/inputdlg.hxx
@@ -28,6 +28,10 @@ public:
private:
+ DECL_LINK(ClickHdl, PushButton*);
+
+private:
+
Edit *mpEntry;
FixedText *mpLabel;
PushButton *mpOK;
commit 7887eeba65abbc19f912a4c5fc67e9699e3f438b
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Wed Jul 4 12:23:26 2012 -0430
Set correct dimensions and positions of inputbox widget.
Change-Id: I31f92f4af90865d8713f50031c08a6fd4498d885
diff --git a/sfx2/AllLangResTarget_sfx2.mk b/sfx2/AllLangResTarget_sfx2.mk
index 418b710..a0bf204 100644
--- a/sfx2/AllLangResTarget_sfx2.mk
+++ b/sfx2/AllLangResTarget_sfx2.mk
@@ -63,6 +63,7 @@ $(eval $(call gb_SrsTarget_add_files,sfx/res,\
sfx2/source/dialog/dinfdlg.src \
sfx2/source/dialog/dinfedt.src \
sfx2/source/dialog/filedlghelper.src \
+ sfx2/source/dialog/inputdlg.src \
sfx2/source/dialog/mailwindow.src \
sfx2/source/dialog/mgetempl.src \
sfx2/source/dialog/newstyle.src \
diff --git a/sfx2/source/dialog/inputdlg.cxx b/sfx2/source/dialog/inputdlg.cxx
index 41d5d4f..74405c8 100644
--- a/sfx2/source/dialog/inputdlg.cxx
+++ b/sfx2/source/dialog/inputdlg.cxx
@@ -9,43 +9,60 @@
#include "inputdlg.hxx"
+#include "inputdlg.hrc"
+
+#include <sfx2/sfxresid.hxx>
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <vcl/fixed.hxx>
-#define LABEL_TEXT_SPACE 10
-#define DIALOG_BORDER 10
-#define MAX_FOLDER_NAME_LENGTH 20
+#define LABEL_TEXT_SPACE 5
InputDialog::InputDialog (const rtl::OUString &rLabelText, Window *pParent)
- : ModalDialog(pParent),
- mpEntry(new Edit(this)),
- mpLabel(new FixedText(this))
+ : ModalDialog(pParent,SfxResId(DLG_INPUT_BOX)),
+ mpEntry(new Edit(this,SfxResId(EDT_INPUT_FIELD))),
+ mpLabel(new FixedText(this,SfxResId(LABEL_INPUT_TEXT))),
+ mpOK(new PushButton(this,SfxResId(BTN_INPUT_OK))),
+ mpCancel(new PushButton(this,SfxResId(BTN_INPUT_CANCEL)))
{
SetStyle(GetStyle() | WB_CENTER | WB_VCENTER);
- Point aPos(DIALOG_BORDER,DIALOG_BORDER);
+ mpLabel->SetText(rLabelText);
+
+ // Fit label size to text and reposition edit box
+ Size aLabelSize = mpLabel->CalcMinimumSize();
+ Size aEditSize = mpEntry->GetSizePixel();
+ Size aBtnSize = mpOK->GetSizePixel();
- Size aTextSize = mpLabel->CalcMinimumTextSize(mpLabel,100);
- Size aEntrySize = mpEntry->CalcSize(MAX_FOLDER_NAME_LENGTH);
+ Point aLabelPos = mpLabel->GetPosPixel();
+ Point aEditPos = mpEntry->GetPosPixel();
- aTextSize.setWidth(aEntrySize.getHeight());
+ aEditPos.setX(aLabelPos.getX() + aLabelSize.getWidth() + LABEL_TEXT_SPACE);
- mpLabel->SetPosPixel(Point(DIALOG_BORDER,DIALOG_BORDER));
- mpLabel->SetSizePixel(aTextSize);
- mpLabel->SetText(String("Enter name"));
+ mpLabel->SetPosSizePixel(aLabelPos,aLabelSize);
+ mpEntry->SetPosSizePixel(aEditPos,aEditSize);
- aPos.setX(DIALOG_BORDER + aTextSize.getWidth() + LABEL_TEXT_SPACE + DIALOG_BORDER);
+ // Resize window if needed
+ Size aWinSize = GetOutputSize();
+ aWinSize.setWidth(aEditPos.getX() + aEditSize.getWidth() + LABEL_TEXT_SPACE);
+ SetSizePixel(aWinSize);
- mpEntry->SetPosPixel(aPos);
- mpEntry->SetSizePixel(aEntrySize);
+ // Align buttons
+ Point aBtnPos = mpCancel->GetPosPixel();
- // Set windows correct size
- SetSizePixel(Size(aTextSize.getWidth() + aEntrySize.getWidth() + 2*DIALOG_BORDER,
- aTextSize.getHeight()+2*DIALOG_BORDER));
+ aBtnPos.setX(aWinSize.getWidth() - aBtnSize.getWidth() - LABEL_TEXT_SPACE);
+ mpCancel->SetPosPixel(aBtnPos);
- mpEntry->Show();
- mpLabel->Show();
+ aBtnPos.setX(aBtnPos.getX() - aBtnSize.getWidth() - LABEL_TEXT_SPACE);
+ mpOK->SetPosPixel(aBtnPos);
+}
+
+InputDialog::~InputDialog()
+{
+ delete mpEntry;
+ delete mpLabel;
+ delete mpOK;
+ delete mpCancel;
}
rtl::OUString InputDialog::getEntryText () const
diff --git a/sfx2/source/dialog/inputdlg.hrc b/sfx2/source/dialog/inputdlg.hrc
index b9fdf70..bb9edd8 100644
--- a/sfx2/source/dialog/inputdlg.hrc
+++ b/sfx2/source/dialog/inputdlg.hrc
@@ -5,3 +5,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+
+#define DLG_INPUT_BOX 256
+#define LABEL_INPUT_TEXT 2
+#define EDT_INPUT_FIELD 3
+#define BTN_INPUT_OK 4
+#define BTN_INPUT_CANCEL 5
diff --git a/sfx2/source/dialog/inputdlg.src b/sfx2/source/dialog/inputdlg.src
index cece9f8..edd16d6 100644
--- a/sfx2/source/dialog/inputdlg.src
+++ b/sfx2/source/dialog/inputdlg.src
@@ -8,3 +8,41 @@
#include "inputdlg.hrc"
+ModalDialog DLG_INPUT_BOX
+{
+ OutputSize = TRUE;
+ SVLook = TRUE;
+ Moveable = TRUE;
+ Closeable = TRUE;
+ Size = MAP_APPFONT ( 215, 40 );
+
+ FixedText LABEL_INPUT_TEXT
+ {
+ Pos = MAP_APPFONT(5,6);
+ Size = MAP_APPFONT(80,10);
+ };
+
+ Edit EDT_INPUT_FIELD
+ {
+ Border = TRUE;
+ Pos = MAP_APPFONT(90,5);
+ Size = MAP_APPFONT(120,10);
+ };
+
+ PushButton BTN_INPUT_OK
+ {
+ Pos = MAP_APPFONT(125,20);
+ Size = MAP_APPFONT(40,15);
+ TabStop = TRUE;
+ DefButton = TRUE;
+ Text [en-US] = "Accept";
+ };
+
+ PushButton BTN_INPUT_CANCEL
+ {
+ Pos = MAP_APPFONT(170,20);
+ Size = MAP_APPFONT(40,15);
+ TabStop = TRUE;
+ Text [en-US] = "Cancel";
+ };
+};
diff --git a/sfx2/source/inc/inputdlg.hxx b/sfx2/source/inc/inputdlg.hxx
index 7e09c9f..0df999d 100644
--- a/sfx2/source/inc/inputdlg.hxx
+++ b/sfx2/source/inc/inputdlg.hxx
@@ -22,6 +22,8 @@ public:
InputDialog (const rtl::OUString &labelText, Window *pParent = NULL);
+ virtual ~InputDialog();
+
rtl::OUString getEntryText () const;
private:
More information about the Libreoffice-commits
mailing list