summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bosdonnat <cedricbosdo@openoffice.org>2010-11-06 19:22:51 +0100
committerCédric Bosdonnat <cedricbosdo@openoffice.org>2011-03-19 17:56:36 +0100
commitc0fa20b9b06bca9f13841078f7d3beb2045843ae (patch)
treeb13d2ae6f19fc26e87d87a4d5c03037e16b6d34a
parent7a336a2f2889ca48ef1bfec2398d32a96233e9d3 (diff)
Nicely draw borders using drawinglayer
-rw-r--r--cui/source/inc/border.hxx5
-rw-r--r--cui/source/tabpages/border.cxx126
-rw-r--r--cui/source/tabpages/border.hrc2
-rw-r--r--cui/source/tabpages/border.src26
4 files changed, 103 insertions, 56 deletions
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index 1d3be2c86..5063610aa 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -78,9 +78,11 @@ private:
FixedLine aFlSep1;
FixedLine aFlLine;
FixedText aStyleFT;
- LineListBox aLbLineStyle;
+ LineStyleListBox aLbLineStyle;
FixedText aColorFT;
ColorListBox aLbLineColor;
+ FixedText aWidthFT;
+ MetricField aLineWidthMF;
FixedLine aFlSep2;
FixedLine aDistanceFL;
@@ -133,6 +135,7 @@ private:
DECL_LINK( SelSdwHdl_Impl, void* );
DECL_LINK( LinesChanged_Impl, void* );
DECL_LINK( ModifyDistanceHdl_Impl, MetricField*);
+ DECL_LINK( ModifyWidthHdl_Impl, void*);
DECL_LINK( SyncHdl_Impl, CheckBox*);
sal_uInt16 GetPresetImageId( sal_uInt16 nValueSetIdx ) const;
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 0a94bc7f2..5858a70cf 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -86,7 +86,6 @@ static sal_uInt16 pRanges[] =
sal_Bool SvxBorderTabPage::bSync = sal_True;
-
//------------------------------------------------------------------------
#define LINE_WIDTH0 (DEF_LINE_WIDTH_0 *100)
@@ -179,6 +178,8 @@ SvxBorderTabPage::SvxBorderTabPage( Window* pParent,
aLbLineStyle ( this, CUI_RES( LB_LINESTYLE ) ),
aColorFT ( this, CUI_RES( FT_COLOR ) ),
aLbLineColor ( this, CUI_RES( LB_LINECOLOR ) ),
+ aWidthFT ( this, CUI_RES( FT_WIDTH ) ),
+ aLineWidthMF ( this, CUI_RES( MF_LINEWIDTH ) ),
aFlSep2 ( this, CUI_RES( FL_SEPARATOR2 ) ),
aDistanceFL ( this, CUI_RES( FL_DISTANCE ) ),
@@ -329,6 +330,7 @@ SvxBorderTabPage::SvxBorderTabPage( Window* pParent,
aFrameSel.SetSelectHdl(LINK(this, SvxBorderTabPage, LinesChanged_Impl));
aLbLineStyle.SetSelectHdl( LINK( this, SvxBorderTabPage, SelStyleHdl_Impl ) );
aLbLineColor.SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
+ aLineWidthMF.SetModifyHdl( LINK( this, SvxBorderTabPage, ModifyWidthHdl_Impl ) );
aLbShadowColor.SetSelectHdl( LINK( this, SvxBorderTabPage, SelColHdl_Impl ) );
aWndPresets.SetSelectHdl( LINK( this, SvxBorderTabPage, SelPreHdl_Impl ) );
aWndShadows.SetSelectHdl( LINK( this, SvxBorderTabPage, SelSdwHdl_Impl ) );
@@ -439,7 +441,6 @@ void SvxBorderTabPage::Reset( const SfxItemSet& rSet )
pBoxItem = (const SvxBoxItem*)GetItem( rSet, SID_ATTR_BORDER_OUTER );
-
pBoxInfoItem = (const SvxBoxInfoItem*)GetItem( rSet, SID_ATTR_BORDER_INNER, sal_False );
eCoreUnit = rSet.GetPool()->GetMetric( nWhichBox );
@@ -552,7 +553,15 @@ void SvxBorderTabPage::Reset( const SfxItemSet& rSet )
SvxBorderStyle nStyle;
bool bWidthEq = aFrameSel.GetVisibleWidth( nPrim, nDist, nSecn, nStyle );
if( bWidthEq )
- aLbLineStyle.SelectEntry( nPrim * 100, nSecn * 100, nDist * 100, nStyle );
+ {
+ // Determine the width first as some styles can be missing depending on it
+ long nWidth = aLbLineStyle.GetWidthFromStyle( nPrim * 5, nSecn * 5, nDist * 5, nStyle );
+ aLineWidthMF.SetValue( sal_Int64( nWidth ) );
+ aLbLineStyle.SetWidth( aLineWidthMF.GetValue( ) );
+
+ // then set the style
+ aLbLineStyle.SelectEntry( nPrim * 5, nSecn * 5, nDist * 5, nStyle );
+ }
else
aLbLineStyle.SelectEntryPos( 1 );
@@ -915,33 +924,30 @@ IMPL_LINK( SvxBorderTabPage, SelColHdl_Impl, ListBox *, pLb )
return 0;
}
-// -----------------------------------------------------------------------
-
-SvxBorderStyle lcl_getBorderStyle( sal_uInt16 nStyle )
+IMPL_LINK( SvxBorderTabPage, ModifyWidthHdl_Impl, void *, EMPTYARG )
{
- SvxBorderStyle nResult = SOLID;
- switch ( nStyle )
- {
- case STYLE_DOTTED:
- nResult = DOTTED;
- break;
- case STYLE_DASHED:
- nResult = DASHED;
- break;
- default:
- nResult = SOLID;
- }
- return nResult;
+ sal_Int64 nVal = aLineWidthMF.GetValue( );
+ aLbLineStyle.SetWidth( nVal );
+
+ aFrameSel.SetStyleToSelection(
+ static_cast< USHORT >( aLbLineStyle.GetSelectEntryLine1() / 5 ),
+ static_cast< USHORT >( aLbLineStyle.GetSelectEntryDistance() / 5 ),
+ static_cast< USHORT >( aLbLineStyle.GetSelectEntryLine2() / 5 ),
+ SvxBorderStyle( aLbLineStyle.GetSelectEntryStyle() ) );
+
+ return 0;
}
+// -----------------------------------------------------------------------
+
IMPL_LINK( SvxBorderTabPage, SelStyleHdl_Impl, ListBox *, pLb )
{
if ( pLb == &aLbLineStyle )
- aFrameSel.SetStyleToSelection(
- static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryLine1() / 100 ),
- static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryDistance() / 100 ),
- static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryLine2() / 100 ),
- lcl_getBorderStyle( aLbLineStyle.GetSelectEntryStyle() ) );
+ aFrameSel.SetStyleToSelection (
+ static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryLine1() / 5 ),
+ static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryDistance() / 5 ),
+ static_cast< sal_uInt16 >( aLbLineStyle.GetSelectEntryLine2() / 5 ),
+ SvxBorderStyle( aLbLineStyle.GetSelectEntryStyle() ) );
return 0;
}
@@ -1090,38 +1096,52 @@ void SvxBorderTabPage::FillValueSets()
}
// ============================================================================
+Color lcl_mediumColor( Color aMain, Color /*aDefault*/ )
+{
+ return SvxBorderLine::threeDMediumColor( aMain );
+}
void SvxBorderTabPage::FillLineListBox_Impl()
{
- aLbLineStyle.SetUnit( FUNIT_POINT );
- aLbLineStyle.SetSourceUnit( FUNIT_TWIP );
-
- // Writer 2.0 Defaults:
- aLbLineStyle.InsertEntry( SVX_RESSTR( RID_SVXSTR_NONE ) );
-
- aLbLineStyle.InsertEntry( LINE_WIDTH0 );
- aLbLineStyle.InsertEntry( LINE_WIDTH5 );
- aLbLineStyle.InsertEntry( LINE_WIDTH5, 0, 0, STYLE_DOTTED );
- aLbLineStyle.InsertEntry( LINE_WIDTH5, 0, 0, STYLE_DASHED );
- aLbLineStyle.InsertEntry( LINE_WIDTH1 );
- aLbLineStyle.InsertEntry( LINE_WIDTH2 );
- aLbLineStyle.InsertEntry( LINE_WIDTH3 );
- aLbLineStyle.InsertEntry( LINE_WIDTH4 );
-
- // OS: wenn hier neue Linienstaerken zugfuegt werden, dann
- // LINESTYLE_HTML_MAX anpassen
-
- aLbLineStyle.InsertEntry( DLINE0_OUT, DLINE0_IN, DLINE0_DIST );
- aLbLineStyle.InsertEntry( DLINE7_OUT, DLINE7_IN, DLINE7_DIST );
- aLbLineStyle.InsertEntry( DLINE1_OUT, DLINE1_IN, DLINE1_DIST );
- aLbLineStyle.InsertEntry( DLINE2_OUT, DLINE2_IN, DLINE2_DIST );
- aLbLineStyle.InsertEntry( DLINE8_OUT, DLINE8_IN, DLINE8_DIST );
- aLbLineStyle.InsertEntry( DLINE9_OUT, DLINE9_IN, DLINE9_DIST );
- aLbLineStyle.InsertEntry( DLINE10_OUT,DLINE10_IN,DLINE10_DIST);
- aLbLineStyle.InsertEntry( DLINE3_OUT, DLINE3_IN, DLINE3_DIST );
- aLbLineStyle.InsertEntry( DLINE4_OUT, DLINE4_IN, DLINE4_DIST );
- aLbLineStyle.InsertEntry( DLINE5_OUT, DLINE5_IN, DLINE5_DIST );
- aLbLineStyle.InsertEntry( DLINE6_OUT, DLINE6_IN, DLINE6_DIST );
+ aLbLineStyle.SetNone( SVX_RESSTR( RID_SVXSTR_NONE ) );
+
+ // Simple lines
+ aLbLineStyle.InsertEntry( 1.0, 0.0, 0.0, CHANGE_LINE1, SOLID );
+ aLbLineStyle.InsertEntry( 1.0, 0.0, 0.0, CHANGE_LINE1, DOTTED );
+ aLbLineStyle.InsertEntry( 1.0, 0.0, 0.0, CHANGE_LINE1, DASHED );
+
+ // Double lines
+ aLbLineStyle.InsertEntry( 1.0, 1.0, 1.0, CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST, DOUBLE );
+ aLbLineStyle.InsertEntry( 1.0, 75.0, 75.0, CHANGE_LINE1, THINTHICK_SMALLGAP, 100 );
+ aLbLineStyle.InsertEntry( 1.0, 0.5, 0.5, CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST, THINTHICK_MEDIUMGAP );
+ aLbLineStyle.InsertEntry( 75.0, 150.0, 1.0, CHANGE_DIST, THINTHICK_LARGEGAP );
+ aLbLineStyle.InsertEntry( 75.0, 1.0, 75.0, CHANGE_LINE2, THICKTHIN_SMALLGAP, 100 );
+ aLbLineStyle.InsertEntry( 0.5, 1.0, 0.5, CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST, THICKTHIN_MEDIUMGAP );
+ aLbLineStyle.InsertEntry( 150.0, 75.0, 1.0, CHANGE_DIST, THICKTHIN_LARGEGAP );
+
+ // Engraved / Embossed
+ /*
+ * Word compat: the lines widths are exactly following this rule, shouldbe:
+ * 0.75pt up to 3pt and then 3pt
+ */
+ aLbLineStyle.InsertEntry( 0.5, 0.5, 1, CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST, EMBOSSED, 75,
+ &SvxBorderLine::threeDLightColor, &SvxBorderLine::threeDDarkColor,
+ &lcl_mediumColor );
+ aLbLineStyle.InsertEntry( 0.5, 0.5, 1, CHANGE_LINE1 | CHANGE_LINE2 | CHANGE_DIST, ENGRAVED, 75,
+ &SvxBorderLine::threeDDarkColor, &SvxBorderLine::threeDLightColor,
+ &lcl_mediumColor );
+
+ // Inset / Outset
+ /*
+ * Word compat: the gap width should be measured relatively to the biggest width for the
+ * row or column.
+ */
+ aLbLineStyle.InsertEntry( 75.0, 1.0, 1.0, CHANGE_LINE2 | CHANGE_DIST, OUTSET, 0.5,
+ &SvxBorderLine::lightColor, &SvxBorderLine::darkColor );
+ aLbLineStyle.InsertEntry( 1.0, 75.0, 1.0, CHANGE_LINE1 | CHANGE_DIST, INSET, 0.5,
+ &SvxBorderLine::darkColor, &SvxBorderLine::lightColor );
+
+ aLbLineStyle.SetWidth( aLineWidthMF.GetValue( ) );
}
// -----------------------------------------------------------------------
diff --git a/cui/source/tabpages/border.hrc b/cui/source/tabpages/border.hrc
index c346ef248..4dcfbf171 100644
--- a/cui/source/tabpages/border.hrc
+++ b/cui/source/tabpages/border.hrc
@@ -37,6 +37,7 @@
#define FL_LINE 20
#define LB_LINESTYLE 21
#define LB_LINECOLOR 22
+#define MF_LINEWIDTH 23
#define FL_SEPARATOR2 29
#define FL_SHADOW 30
@@ -67,6 +68,7 @@
#define FL_PROPERTIES 64
#define CB_MERGEWITHNEXT 65
#define CB_MERGEADJACENTBORDERS 66
+#define FT_WIDTH 67
// ImageListe fuer ValueSets:
#define IL_PRE_BITMAPS 1400
diff --git a/cui/source/tabpages/border.src b/cui/source/tabpages/border.src
index 3d2d295c9..10599d5e8 100644
--- a/cui/source/tabpages/border.src
+++ b/cui/source/tabpages/border.src
@@ -97,10 +97,32 @@ TabPage RID_SVXPAGE_BORDER
Border = TRUE ;
Pos = MAP_APPFONT ( 88 , 25 ) ;
Size = MAP_APPFONT ( 74 , 66 ) ;
+ DropDown = TRUE ;
+ };
+ FixedText FT_WIDTH
+ {
+ Pos = MAP_APPFONT ( 88, 39 ) ;
+ Size = MAP_APPFONT ( 77, 8 ) ;
+ Text [ en-US ] = "~Width";
+ };
+ MetricField MF_LINEWIDTH
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 88 , 50 ) ;
+ Size = MAP_APPFONT ( 74 , 12 ) ;
+ Spin = TRUE ;
+ Repeat = TRUE ;
+ SpinSize = 25 ;
+ First = 25 ;
+ Last = 900 ;
+ Maximum = 900 ;
+ Minimum = 25 ;
+ DecimalDigits = 2 ;
+ Unit = FUNIT_POINT ;
};
FixedText FT_COLOR
{
- Pos = MAP_APPFONT ( 88, 95 ) ;
+ Pos = MAP_APPFONT ( 88, 64 ) ;
Size = MAP_APPFONT ( 77, 8 ) ;
Text [ en-US ] = "~Color";
};
@@ -108,7 +130,7 @@ TabPage RID_SVXPAGE_BORDER
{
HelpID = "cui:ListBox:RID_SVXPAGE_BORDER:LB_LINECOLOR";
Border = TRUE ;
- Pos = MAP_APPFONT ( 88 , 106 ) ;
+ Pos = MAP_APPFONT ( 88 , 75 ) ;
Size = MAP_APPFONT ( 74 , 68 ) ;
DropDown = TRUE ;
DDExtraWidth = TRUE ;