diff options
author | Rafael Dominguez <venccsralph@gmail.com> | 2012-07-04 12:23:26 -0430 |
---|---|---|
committer | Rafael Dominguez <venccsralph@gmail.com> | 2012-07-04 12:23:26 -0430 |
commit | 7887eeba65abbc19f912a4c5fc67e9699e3f438b (patch) | |
tree | cf144839a397c5c763a59bde1eb1e9511319fb86 | |
parent | 40ec7e20e369f241a748808ba85fd5fc34980eb5 (diff) |
Set correct dimensions and positions of inputbox widget.
Change-Id: I31f92f4af90865d8713f50031c08a6fd4498d885
-rw-r--r-- | sfx2/AllLangResTarget_sfx2.mk | 1 | ||||
-rw-r--r-- | sfx2/source/dialog/inputdlg.cxx | 59 | ||||
-rw-r--r-- | sfx2/source/dialog/inputdlg.hrc | 6 | ||||
-rw-r--r-- | sfx2/source/dialog/inputdlg.src | 38 | ||||
-rw-r--r-- | sfx2/source/inc/inputdlg.hxx | 2 |
5 files changed, 85 insertions, 21 deletions
diff --git a/sfx2/AllLangResTarget_sfx2.mk b/sfx2/AllLangResTarget_sfx2.mk index 418b7101e73f..a0bf2045ebea 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 41d5d4f48635..74405c884b15 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 b9fdf70c2edd..bb9edd8cb11a 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 cece9f887f8c..edd16d698001 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 7e09c9fee550..0df999db8678 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: |