Kaydet (Commit) a591f0dd authored tarafından Caolán McNamara's avatar Caolán McNamara

adapt code to spacing dialog .ui conversion

Change-Id: I4ec9444b3ad0d243fda0d93547f000cb7296c0bc
üst 4881ec4a
......@@ -27,6 +27,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/smath,\
starmath/uiconfig/smath/ui/alignmentdialog \
starmath/uiconfig/smath/ui/catalogdialog \
starmath/uiconfig/smath/ui/printeroptions \
starmath/uiconfig/smath/ui/spacingdialog \
))
# vim: set noet sw=4 ts=4:
......@@ -23,6 +23,7 @@
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
#include <vcl/layout.hxx>
#include <sfx2/tabdlg.hxx>
#include <vcl/combobox.hxx>
#include <svx/charmap.hxx>
......@@ -194,17 +195,17 @@ public:
#define NOCATEGORIES 10
class SmCategoryDesc : public Resource
class SmCategoryDesc
{
OUString Name;
OUString Name;
OUString *Strings[4];
Bitmap *Graphics[4]; /* regular bitmaps */
sal_uInt16 Minimum[4];
sal_uInt16 Maximum[4];
sal_uInt16 Value[4];
Image *Graphics[4]; /* regular bitmaps */
sal_uInt16 Minimum[4];
sal_uInt16 Maximum[4];
sal_uInt16 Value[4];
public:
SmCategoryDesc(const ResId &rResId, sal_uInt16 nCategoryIdx);
SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCategoryIdx);
~SmCategoryDesc();
const OUString& GetName() const { return Name; }
......@@ -214,7 +215,7 @@ public:
sal_uInt16 GetValue(sal_uInt16 Index) const { return Value[Index]; }
void SetValue(sal_uInt16 Index, sal_uInt16 nVal) { Value[Index] = nVal;}
const Bitmap * GetGraphic(sal_uInt16 Index) const
const Image * GetGraphic(sal_uInt16 Index) const
{
return Graphics[Index];
}
......@@ -223,22 +224,19 @@ public:
class SmDistanceDialog : public ModalDialog
{
FixedText aFixedText1;
MetricField aMetricField1;
FixedText aFixedText2;
MetricField aMetricField2;
FixedText aFixedText3;
MetricField aMetricField3;
CheckBox aCheckBox1;
FixedText aFixedText4;
MetricField aMetricField4;
OKButton aOKButton1;
HelpButton aHelpButton1;
CancelButton aCancelButton1;
MenuButton aMenuButton;
PushButton aDefaultButton;
FixedBitmap aBitmap;
FixedLine aFixedLine;
VclFrame* m_pFrame;
FixedText* m_pFixedText1;
MetricField* m_pMetricField1;
FixedText* m_pFixedText2;
MetricField* m_pMetricField2;
FixedText* m_pFixedText3;
MetricField* m_pMetricField3;
CheckBox* m_pCheckBox1;
FixedText* m_pFixedText4;
MetricField* m_pMetricField4;
MenuButton* m_pMenuButton;
PushButton* m_pDefaultButton;
FixedImage* m_pBitmap;
SmCategoryDesc *Categories[NOCATEGORIES];
sal_uInt16 nActiveCategory;
......@@ -247,7 +245,6 @@ class SmDistanceDialog : public ModalDialog
DECL_LINK(GetFocusHdl, Control *);
DECL_LINK(MenuSelectHdl, Menu *);
DECL_LINK(DefaultButtonClickHdl, Button *);
DECL_LINK(HelpButtonClickHdl, Button *);
DECL_LINK(CheckBoxClickHdl, CheckBox *);
using Window::SetHelpId;
......@@ -255,7 +252,7 @@ class SmDistanceDialog : public ModalDialog
void SetCategory(sal_uInt16 Category);
public:
SmDistanceDialog(Window *pParent, bool bFreeRes = true);
SmDistanceDialog(Window *pParent);
~SmDistanceDialog();
void ReadFrom(const SmFormat &rFormat);
......
......@@ -84,7 +84,6 @@
#define RID_FONTDIALOG (RID_APP_START + 2)
#define RID_FONTSIZEDIALOG (RID_APP_START + 3)
#define RID_FONTTYPEDIALOG (RID_APP_START + 4)
#define RID_DISTANCEDIALOG (RID_APP_START + 5)
#define RID_PRINTOPTIONPAGE (RID_APP_START + 7)
#define RID_SYMDEFINEDIALOG (RID_APP_START + 9)
#define RID_PRINTUIOPTIONS (RID_APP_START + 11)
......@@ -99,7 +98,6 @@
#define RID_UNDOFORMATNAME (RID_APP_START + 504)
#define RID_COMMANDMENU (RID_APP_START + 701)
#define RID_VIEWMENU (RID_APP_START + 702)
#define RID_DISTANCEMENU (RID_APP_START + 703)
#define RID_FONTMENU (RID_APP_START + 704)
#define RID_TOOLBOXWINDOW (RID_APP_START + 801)
#define RID_CMDBOXWINDOW (RID_APP_START + 802)
......
......@@ -683,45 +683,40 @@ static const FieldMinMax pMinMaxData[10][4] =
{{ 0, 10000 }, { 0, 10000 }, { 0, 10000 }, { 0, 10000 }}
};
SmCategoryDesc::SmCategoryDesc(const ResId& rResId, sal_uInt16 nCategoryIdx) :
Resource(rResId)
SmCategoryDesc::SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCategoryIdx)
{
if (IsAvailableRes(ResId(1,*rResId.GetResMgr()).SetRT(RSC_STRING)))
++nCategoryIdx;
FixedText *pTitle = rBuilder.get<FixedText>(OString::number(nCategoryIdx)+"title");
if (pTitle)
{
Name = ResId(1,*rResId.GetResMgr()).toString();
Name = pTitle->GetText();
int i;
for (i = 0; i < 4; i++)
for (int i = 0; i < 4; ++i)
{
int nI2 = i + 2;
FixedText *pLabel = rBuilder.get<FixedText>(OString::number(nCategoryIdx)+"label"+OString::number(i+1));
if (IsAvailableRes(ResId(nI2,*rResId.GetResMgr()).SetRT(RSC_STRING)))
if (pLabel)
{
Strings [i] = new OUString(ResId(nI2,*rResId.GetResMgr()).toString());
Graphics [i] = new Bitmap(ResId(10*nI2,*rResId.GetResMgr()));
Strings [i] = new OUString(pLabel->GetText());
FixedImage *pImage = rBuilder.get<FixedImage>(OString::number(nCategoryIdx)+"image"+OString::number(i+1));
Graphics [i] = new Image(pImage->GetImage());
}
else
{
Strings [i] = 0;
Graphics [i] = 0;
}
}
for (i = 0; i < 4; i++)
{
const FieldMinMax &rMinMax = pMinMaxData[ nCategoryIdx ][i];
Value[i] = Minimum[i] = rMinMax.nMin;
Maximum[i] = rMinMax.nMax;
}
}
FreeResource();
}
SmCategoryDesc::~SmCategoryDesc()
{
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; ++i)
{
delete Strings [i];
delete Graphics [i];
......@@ -736,17 +731,17 @@ IMPL_LINK( SmDistanceDialog, GetFocusHdl, Control *, pControl )
{
sal_uInt16 i;
if (pControl == &aMetricField1)
if (pControl == m_pMetricField1)
i = 0;
else if (pControl == &aMetricField2)
else if (pControl == m_pMetricField2)
i = 1;
else if (pControl == &aMetricField3)
else if (pControl == m_pMetricField3)
i = 2;
else if (pControl == &aMetricField4)
else if (pControl == m_pMetricField4)
i = 3;
else
return 0;
aBitmap.SetBitmap(*(Categories[nActiveCategory]->GetGraphic(i)));
m_pBitmap->SetImage(*(Categories[nActiveCategory]->GetGraphic(i)));
}
return 0;
}
......@@ -773,27 +768,15 @@ IMPL_LINK( SmDistanceDialog, DefaultButtonClickHdl, Button *, EMPTYARG /*pButton
return 0;
}
IMPL_LINK( SmDistanceDialog, HelpButtonClickHdl, Button *, EMPTYARG /*pButton*/ )
{
// start help system
Help* pHelp = Application::GetHelp();
if( pHelp )
{
pHelp->Start( OUString( "HID_SMA_DISTANCEDIALOG" ), &aHelpButton1 );
}
return 0;
}
IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, CheckBox *, pCheckBox )
{
if (pCheckBox == &aCheckBox1)
if (pCheckBox == m_pCheckBox1)
{
aCheckBox1.Toggle();
m_pCheckBox1->Toggle();
bool bChecked = aCheckBox1.IsChecked();
aFixedText4 .Enable( bChecked );
aMetricField4.Enable( bChecked );
bool bChecked = m_pCheckBox1->IsChecked();
m_pFixedText4->Enable( bChecked );
m_pMetricField4->Enable( bChecked );
}
return 0;
}
......@@ -847,10 +830,10 @@ void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
// array to help iterate over the controls
Window * const aWin[4][2] =
{
{ &aFixedText1, &aMetricField1 },
{ &aFixedText2, &aMetricField2 },
{ &aFixedText3, &aMetricField3 },
{ &aFixedText4, &aMetricField4 }
{ m_pFixedText1, m_pMetricField1 },
{ m_pFixedText2, m_pMetricField2 },
{ m_pFixedText3, m_pMetricField3 },
{ m_pFixedText4, m_pMetricField4 }
};
SmCategoryDesc *pCat;
......@@ -860,15 +843,15 @@ void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
if (nActiveCategory != CATEGORY_NONE)
{
pCat = Categories[nActiveCategory];
pCat->SetValue(0, (sal_uInt16) aMetricField1.GetValue());
pCat->SetValue(1, (sal_uInt16) aMetricField2.GetValue());
pCat->SetValue(2, (sal_uInt16) aMetricField3.GetValue());
pCat->SetValue(3, (sal_uInt16) aMetricField4.GetValue());
pCat->SetValue(0, (sal_uInt16) m_pMetricField1->GetValue());
pCat->SetValue(1, (sal_uInt16) m_pMetricField2->GetValue());
pCat->SetValue(2, (sal_uInt16) m_pMetricField3->GetValue());
pCat->SetValue(3, (sal_uInt16) m_pMetricField4->GetValue());
if (nActiveCategory == 5)
bScaleAllBrackets = aCheckBox1.IsChecked();
bScaleAllBrackets = m_pCheckBox1->IsChecked();
aMenuButton.GetPopupMenu()->CheckItem(nActiveCategory + 1, false);
m_pMenuButton->GetPopupMenu()->CheckItem(nActiveCategory + 1, false);
}
// activation/deactivation of the associated controls depending on the chosen category
......@@ -918,68 +901,63 @@ void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
}
// activate the CheckBox and the associated MetricField if we're dealing with the brackets menu
bActive = nCategory == 5;
aCheckBox1.Show(bActive);
aCheckBox1.Enable(bActive);
m_pCheckBox1->Show(bActive);
m_pCheckBox1->Enable(bActive);
if (bActive)
{
aCheckBox1.Check( bScaleAllBrackets );
m_pCheckBox1->Check( bScaleAllBrackets );
bool bChecked = aCheckBox1.IsChecked();
aFixedText4 .Enable( bChecked );
aMetricField4.Enable( bChecked );
bool bChecked = m_pCheckBox1->IsChecked();
m_pFixedText4->Enable( bChecked );
m_pMetricField4->Enable( bChecked );
}
aMenuButton.GetPopupMenu()->CheckItem(nCategory + 1, true);
aFixedLine.SetText(Categories[nCategory]->GetName());
m_pMenuButton->GetPopupMenu()->CheckItem(nCategory + 1, true);
m_pFrame->set_label(Categories[nCategory]->GetName());
nActiveCategory = nCategory;
aMetricField1.GrabFocus();
m_pMetricField1->GrabFocus();
Invalidate();
Update();
}
SmDistanceDialog::SmDistanceDialog(Window *pParent, bool bFreeRes)
: ModalDialog(pParent, SmResId(RID_DISTANCEDIALOG)),
aFixedText1 (this, SmResId(1)),
aMetricField1 (this, SmResId(1)),
aFixedText2 (this, SmResId(2)),
aMetricField2 (this, SmResId(2)),
aFixedText3 (this, SmResId(3)),
aMetricField3 (this, SmResId(3)),
aCheckBox1 (this, SmResId(1)),
aFixedText4 (this, SmResId(4)),
aMetricField4 (this, SmResId(4)),
aOKButton1 (this, SmResId(1)),
aHelpButton1 (this, SmResId(1)),
aCancelButton1 (this, SmResId(1)),
aMenuButton (this, SmResId(1)),
aDefaultButton (this, SmResId(1)),
aBitmap (this, SmResId(1)),
aFixedLine (this, SmResId(1))
SmDistanceDialog::SmDistanceDialog(Window *pParent)
: ModalDialog(pParent, "SpacingDialog",
"modules/smath/ui/spacingdialog.ui")
{
for (sal_uInt16 i = 0; i < NOCATEGORIES; i++)
Categories[i] = new SmCategoryDesc(SmResId(i + 1), i);
get(m_pFrame, "template");
get(m_pFixedText1, "label1");
get(m_pMetricField1, "spinbutton1");
get(m_pFixedText2, "label2");
get(m_pMetricField2, "spinbutton2");
get(m_pFixedText3, "label3");
get(m_pMetricField3, "spinbutton3");
get(m_pCheckBox1, "checkbutton");
get(m_pFixedText4, "label4");
get(m_pMetricField4, "spinbutton4");
get(m_pMenuButton, "category");
get(m_pDefaultButton, "default");
get(m_pBitmap, "image");
for (sal_uInt16 i = 0; i < NOCATEGORIES; ++i)
Categories[i] = new SmCategoryDesc(*this, i);
nActiveCategory = CATEGORY_NONE;
bScaleAllBrackets = false;
if (bFreeRes)
FreeResource();
// preview like controls should have a 2D look
aBitmap.SetBorderStyle( WINDOW_BORDER_MONO );
m_pBitmap->SetBorderStyle( WINDOW_BORDER_MONO );
aMetricField1.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
aMetricField2.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
aMetricField3.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
aMetricField4.SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
aCheckBox1.SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
m_pMetricField1->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pMetricField2->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pMetricField3->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pMetricField4->SetGetFocusHdl(LINK(this, SmDistanceDialog, GetFocusHdl));
m_pCheckBox1->SetClickHdl(LINK(this, SmDistanceDialog, CheckBoxClickHdl));
aMenuButton.GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
m_pMenuButton->GetPopupMenu()->SetSelectHdl(LINK(this, SmDistanceDialog, MenuSelectHdl));
aDefaultButton.SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
aHelpButton1.SetClickHdl(LINK(this, SmDistanceDialog, HelpButtonClickHdl));
m_pDefaultButton->SetClickHdl(LINK(this, SmDistanceDialog, DefaultButtonClickHdl));
}
......
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment