You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by af...@apache.org on 2013/03/05 13:17:10 UTC
svn commit: r1452760 [4/5] - in /openoffice/branches/sidebar/main:
default_images/sfx2/res/symphony/
officecfg/registry/data/org/openoffice/Office/UI/ sd/source/ui/sidebar/
sfx2/inc/sfx2/sidebar/ sfx2/source/sidebar/ svx/ svx/inc/sidebar/
svx/inc/svx/s...
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStylePopup.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStylePopup.hxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStylePopup.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStylePopup.hxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,55 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _SVX_SIDEBAR_LINE_STYLE_POPUP_HXX_
+#define _SVX_SIDEBAR_LINE_STYLE_POPUP_HXX_
+
+#include "svx/sidebar/Popup.hxx"
+
+#include <boost/function.hpp>
+
+class XLineStyleItem;
+class XLineDashItem;
+
+namespace svx { namespace sidebar {
+
+class LineStylePopup
+ : public Popup
+{
+public :
+ LineStylePopup (
+ Window* pParent,
+ const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator);
+ virtual ~LineStylePopup (void);
+
+ void SetStyleSelect (
+ XLineStyleItem* pStyleItem,
+ XLineDashItem* pDashItem,
+ const bool bIsStyleItemAvailable,
+ const bool bIsDashItemAvailable);
+
+protected:
+ virtual void CreateContainerAndControl (void);
+};
+
+} } // end of namespace svx::sidebar
+
+#endif
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,132 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "LineStyleValueSet.hxx"
+
+#include <i18npool/mslangid.hxx>
+
+
+namespace svx { namespace sidebar {
+
+LineStyleValueSet::LineStyleValueSet (
+ Window* pParent,
+ const ResId& rResId)
+ : ValueSet( pParent, rResId ),
+ pVDev(NULL),
+ mbSelectFirst(true)
+{
+ SetColCount( 1 );
+}
+
+
+
+
+LineStyleValueSet::~LineStyleValueSet (void)
+{
+ delete pVDev;
+}
+
+
+
+
+void LineStyleValueSet::SetFirstString(XubString str)
+{
+ strNone = str;
+}
+
+
+
+
+void LineStyleValueSet::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ Rectangle aRect = rUDEvt.GetRect();
+ OutputDevice* pDev = rUDEvt.GetDevice();
+ sal_uInt16 nItemId = rUDEvt.GetItemId();
+
+ long nRectHeight = aRect.GetHeight();
+ long nRectWidth = aRect.GetWidth();
+ Point aBLPos = aRect.TopLeft();
+ if(nItemId == 1)
+ {
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ Color aOldFillColor = pDev->GetFillColor();
+ const Color aTextColor = rStyleSettings.GetFieldTextColor();
+
+ //draw back
+ if( mbSelectFirst )
+ {
+ Color aBackColor(50,107,197);
+ Rectangle aBackRect = aRect;
+ aBackRect.Top() += 3;
+ aBackRect.Bottom() -= 2;
+ pDev->SetFillColor(aBackColor);
+ pDev->DrawRect(aBackRect);
+ }
+ else
+ {
+ pDev->SetFillColor( COL_TRANSPARENT );
+ pDev->DrawRect(aRect);
+ }
+ pDev->SetFillColor(aOldFillColor);
+
+ //draw text
+ Font aOldFont = pDev->GetFont();
+ Color aOldColor = pDev->GetLineColor();
+ Font aFont(OutputDevice::GetDefaultFont(
+ DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
+ Size aSize = aFont.GetSize();
+ aSize.Height() = nRectHeight*3/5;
+ if( mbSelectFirst )
+ aFont.SetColor(COL_WHITE);
+ else
+ //aFont.SetColor(COL_BLACK);
+ aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor()); //high contrast
+ aFont.SetFillColor(COL_BLUE);
+ aFont.SetSize( aSize );
+ pDev->SetFont(aFont);
+// String sText("None", 9, RTL_TEXTENCODING_ASCII_US);
+
+ // Point aStart(aBLPos.X() + 8 , aBLPos.Y() + nRectHeight/6);
+ Rectangle aStrRect = aRect;
+ aStrRect.Top() += nRectHeight/6;
+ aStrRect.Bottom() -= nRectHeight/6;
+ aStrRect.Left() += 8;
+ pDev->DrawText(aStrRect, strNone, TEXT_DRAW_ENDELLIPSIS);
+
+ pDev->SetFont(aOldFont);
+ pDev->SetLineColor(aOldColor);
+
+
+ }
+ Invalidate( aRect );
+}
+
+
+
+
+void LineStyleValueSet::SetFirstSelect(bool bSel)
+{
+ mbSelectFirst = bSel;
+}
+
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.hxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineStyleValueSet.hxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,77 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+/*
+#include <sfx2/sidebar/propertypanel.hrc>
+#include <sfx2/sidebar/Theme.hxx>
+#include <sfx2/sidebar/ControlFactory.hxx>
+#include <LinePropertyPanel.hxx>
+#include <LinePropertyPanel.hrc>
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <svx/xlnclit.hxx>
+#include <svx/xtable.hxx>
+#include <svx/xdash.hxx>
+#include <svx/drawitem.hxx>
+#include <svx/svxitems.hrc>
+#include <unotools/pathoptions.hxx>
+#include <unotools/viewoptions.hxx>
+#include <comphelper/processfactory.hxx>
+#include <i18npool/mslangid.hxx>
+#include <svx/xlineit0.hxx>
+#include <svx/xlndsit.hxx>
+#include <vcl/svapp.hxx>
+#include <svx/xlnwtit.hxx>
+#include <vcl/lstbox.hxx>
+#include <svx/tbxcolorupdate.hxx>
+#include <vcl/toolbox.hxx>
+#include <svx/xlntrit.hxx>
+#include <svx/xlnstit.hxx>
+#include <svx/xlnedit.hxx>
+#include <svx/xlncapit.hxx>
+#include <svx/xlinjoit.hxx>
+#include <svx/sidebar/PopupControl.hxx>
+*/
+#include <svtools/valueset.hxx>
+
+namespace svx { namespace sidebar {
+
+class LineStyleValueSet
+ : public ValueSet
+{
+public:
+ LineStyleValueSet (Window* pParent, const ResId& rResId);
+ virtual ~LineStyleValueSet (void);
+
+ void SetFirstSelect(bool bSel);
+ void SetFirstString(XubString str);
+
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+
+private:
+ VirtualDevice* pVDev;
+ bool mbSelectFirst;
+ XubString strNone;
+};
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,374 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "LineWidthControl.hxx"
+#include "LinePropertyPanel.hrc"
+#include "LinePropertyPanel.hxx"
+
+#include <svx/dialogs.hrc>
+#include <svx/dialmgr.hxx>
+#include <sfx2/sidebar/propertypanel.hrc>
+#include <comphelper/processfactory.hxx>
+#include <vcl/svapp.hxx>
+#include <unotools/viewoptions.hxx>
+#include <svx/xlnwtit.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include "svx/sidebar/PopupContainer.hxx"
+
+
+namespace svx { namespace sidebar {
+
+LineWidthControl::LineWidthControl (
+ Window* pParent,
+ LinePropertyPanel& rPanel)
+ : svx::sidebar::PopupControl(pParent,SVX_RES(RID_POPUPPANEL_LINEPAGE_WIDTH)),
+ mrLinePropertyPanel(rPanel),
+ mpBindings(NULL),
+ maVSWidth( this, SVX_RES(VS_WIDTH)),
+ maFTCus( this, SVX_RES(FT_CUSTOME)),
+ maFTWidth( this, SVX_RES(FT_LINE_WIDTH)),
+ maMFWidth( this, SVX_RES(MF_WIDTH)),
+ meMapUnit(SFX_MAPUNIT_TWIP),
+ rStr(NULL),
+ mstrPT(SVX_RES(STR_PT)),
+ mnCustomWidth(0),
+ mbCustom(false),
+ mbColseByEdit(false),
+ mnTmpCusomWidth(0),
+ mbVSFocus(true),
+ maIMGCus(SVX_RES(IMG_WIDTH_CUSTOM)),
+ maIMGCusGray(SVX_RES(IMG_WIDTH_CUSTOM_GRAY))
+{
+ Initialize();
+ FreeResource();
+ mpBindings = mrLinePropertyPanel.GetBindings();
+}
+
+
+
+
+LineWidthControl::~LineWidthControl (void)
+{
+ delete[] rStr;
+}
+
+
+
+
+void LineWidthControl::Paint(const Rectangle& rect)
+{
+ svx::sidebar::PopupControl::Paint(rect);
+
+ Color aOldLineColor = GetLineColor();
+ Color aOldFillColor = GetFillColor();
+
+ Point aPos( LogicToPixel( Point( CUSTOM_X, CUSTOM_Y), MAP_APPFONT ));
+ Size aSize( LogicToPixel( Size( CUSTOM_W, CUSTOM_H ), MAP_APPFONT ));
+ Rectangle aRect( aPos, aSize );
+ aRect.Left() -= 1;
+ aRect.Top() -= 1;
+ aRect.Right() += 1;
+ aRect.Bottom() += 1;
+
+ Color aLineColor(189,201,219);
+ if(!GetSettings().GetStyleSettings().GetHighContrastMode())
+ SetLineColor(aLineColor);
+ else
+ SetLineColor(GetSettings().GetStyleSettings().GetShadowColor());
+ SetFillColor(COL_TRANSPARENT);
+ DrawRect(aRect);
+
+ SetLineColor(aOldLineColor);
+ SetFillColor(aOldFillColor);
+}
+
+
+
+
+void LineWidthControl::Initialize()
+{
+ maVSWidth.SetStyle( maVSWidth.GetStyle()| WB_3DLOOK | WB_NO_DIRECTSELECT );// WB_NAMEFIELD | WB_ITEMBORDER |WB_DOUBLEBORDER | WB_NONEFIELD |
+ //for high contract wj
+ if(GetSettings().GetStyleSettings().GetHighContrastMode())
+ {
+ maVSWidth.SetColor(GetSettings().GetStyleSettings().GetMenuColor());
+ // maBorder.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+ maFTWidth.SetBackground(GetSettings().GetStyleSettings().GetMenuColor());
+ }
+ else
+ {
+ maVSWidth.SetColor(COL_WHITE);
+ // maBorder.SetBackground(Wallpaper(COL_WHITE));
+ maFTWidth.SetBackground(Wallpaper(COL_WHITE));
+ }
+
+ sal_Int64 nFirst= maMFWidth.Denormalize( maMFWidth.GetFirst( FUNIT_TWIP ) );
+ sal_Int64 nLast = maMFWidth.Denormalize( maMFWidth.GetLast( FUNIT_TWIP ) );
+ sal_Int64 nMin = maMFWidth.Denormalize( maMFWidth.GetMin( FUNIT_TWIP ) );
+ sal_Int64 nMax = maMFWidth.Denormalize( maMFWidth.GetMax( FUNIT_TWIP ) );
+ maMFWidth.SetSpinSize( 10 );
+ maMFWidth.SetUnit( FUNIT_POINT );
+ if( maMFWidth.GetDecimalDigits() > 1 )
+ maMFWidth.SetDecimalDigits( 1 );
+ maMFWidth.SetFirst( maMFWidth.Normalize( nFirst ), FUNIT_TWIP );
+ maMFWidth.SetLast( maMFWidth.Normalize( nLast ), FUNIT_TWIP );
+ maMFWidth.SetMin( maMFWidth.Normalize( nMin ), FUNIT_TWIP );
+ maMFWidth.SetMax( maMFWidth.Normalize( nMax ), FUNIT_TWIP );
+
+ rStr = new XubString[9];
+ //modify,
+ rStr[0] = String("05", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[1] = String("08", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[2] = String("10", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[3] = String("15", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[4] = String("23", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[5] = String("30", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[6] = String("45", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[7] = String("60", 2, RTL_TEXTENCODING_ASCII_US);
+ rStr[8] = String( SVX_RES(STR_WIDTH_LAST_CUSTOM) );
+
+ LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), Application::GetSettings().GetLocale() );
+ const sal_Unicode cSep = aLocaleWrapper.getNumDecimalSep().GetChar(0);
+
+ for(int i = 0; i <= 7 ; i++)
+ {
+ rStr[i] = rStr[i].Insert(cSep, 1);//Modify
+ rStr[i].Append(mstrPT);
+ }
+ //end
+
+ for(sal_uInt16 i = 1 ; i <= 9 ; i++)
+ {
+ maVSWidth.InsertItem(i);
+ maVSWidth.SetItemText(i, rStr[i-1]);
+ }
+ maVSWidth.SetUnit(rStr);
+ maVSWidth.SetItemData(1,(void*)5);
+ maVSWidth.SetItemData(2,(void*)8);
+ maVSWidth.SetItemData(3,(void*)10);
+ maVSWidth.SetItemData(4,(void*)15);
+ maVSWidth.SetItemData(5,(void*)23);
+ maVSWidth.SetItemData(6,(void*)30);
+ maVSWidth.SetItemData(7,(void*)45);
+ maVSWidth.SetItemData(8,(void*)60);
+ maVSWidth.SetImage(maIMGCusGray);
+
+ maVSWidth.SetSelItem(0);
+ Link aLink = LINK( this, LineWidthControl, VSSelectHdl ) ;
+ maVSWidth.SetSelectHdl(aLink);
+ aLink = LINK(this, LineWidthControl, MFModifyHdl);
+ maMFWidth.SetModifyHdl(aLink);
+
+ maVSWidth.StartSelection();
+ maVSWidth.Show();
+}
+
+
+
+
+void LineWidthControl::GetFocus()
+{
+ if(!mbVSFocus)
+ maMFWidth.GrabFocus();
+ else
+ maVSWidth.GrabFocus();
+}
+
+
+
+
+ValueSet& LineWidthControl::GetValueSet()
+{
+ return maVSWidth;
+}
+
+
+
+
+void LineWidthControl::SetWidthSelect( long lValue, bool bValuable, SfxMapUnit eMapUnit)
+{
+ mbVSFocus = true;
+ maVSWidth.SetSelItem(0);
+ mbColseByEdit = false;
+ meMapUnit = eMapUnit;
+ SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_LINE_WIDTH_GLOBAL_VALUE );
+ if ( aWinOpt.Exists() )
+ {
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq = aWinOpt.GetUserData();
+ ::rtl::OUString aTmp;
+ if ( aSeq.getLength())
+ aSeq[0].Value >>= aTmp;
+
+ String aWinData( aTmp );
+ mnCustomWidth = aWinData.ToInt32();
+ mbCustom = true;
+ maVSWidth.SetImage(maIMGCus);
+ maVSWidth.SetCusEnable(true);
+
+ String aStrTip( String::CreateFromDouble( (double)mnCustomWidth / 10));
+ aStrTip.Append(mstrPT); //
+ maVSWidth.SetItemText(9, aStrTip);
+ }
+ else
+ {
+ mbCustom = false;
+ maVSWidth.SetImage(maIMGCusGray);
+ maVSWidth.SetCusEnable(false);
+ //modify
+ //String aStrTip(String(SVX_RES(STR_WIDTH_LAST_CUSTOM)));
+ //maVSWidth.SetItemText(9, aStrTip);
+ maVSWidth.SetItemText(9, rStr[8]);
+ }
+
+ if(bValuable)
+ {
+ sal_Int64 nVal = OutputDevice::LogicToLogic( lValue, (MapUnit)eMapUnit, MAP_100TH_MM );
+ nVal = maMFWidth.Normalize( nVal );
+ maMFWidth.SetValue( nVal, FUNIT_100TH_MM );
+ }
+ else
+ {
+ maMFWidth.SetText( String() );
+ }
+
+ MapUnit eOrgUnit = (MapUnit)eMapUnit;
+ MapUnit ePntUnit( MAP_TWIP );
+ lValue = LogicToLogic( lValue , eOrgUnit, ePntUnit );
+
+ XubString strCurrValue = maMFWidth.GetText();
+ sal_uInt16 i = 0;
+ for(; i < 8; i++)
+ if(strCurrValue == rStr[i])
+ {
+ maVSWidth.SetSelItem(i+1);
+ break;
+ }
+ if (i>=8)
+ {
+ mbVSFocus = false;
+ maVSWidth.SetSelItem(0);
+ }
+ maVSWidth.Format();
+ maVSWidth.StartSelection();
+}
+
+
+
+
+IMPL_LINK(LineWidthControl, VSSelectHdl, void *, pControl)
+{
+ if(pControl == &maVSWidth)
+ {
+ sal_uInt16 iPos = maVSWidth.GetSelectItemId();
+ if(iPos >= 1 && iPos <= 8)
+ {
+ long nVal = LogicToLogic((long)(unsigned long)maVSWidth.GetItemData( iPos ) , MAP_POINT, (MapUnit)meMapUnit);
+ nVal = maMFWidth.Denormalize(nVal);
+ XLineWidthItem aWidthItem( nVal );
+ mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aWidthItem, 0L);
+ mrLinePropertyPanel.SetWidthIcon(iPos);
+ mrLinePropertyPanel.SetWidth(nVal);
+ mbColseByEdit = false;
+ mnTmpCusomWidth = 0;
+ }
+ else if(iPos == 9)
+ {//last custom
+ //modified
+ if(mbCustom)
+ {
+ long nVal = LogicToLogic(mnCustomWidth , MAP_POINT, (MapUnit)meMapUnit);
+ nVal = maMFWidth.Denormalize(nVal);
+ XLineWidthItem aWidthItem( nVal );
+ mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aWidthItem, 0L);
+ mrLinePropertyPanel.SetWidth(nVal);
+ mbColseByEdit = false;
+ mnTmpCusomWidth = 0;
+ }
+ else
+ {
+ maVSWidth.SetNoSelection(); //add , set no selection and keep the last select item
+ maVSWidth.Format();
+ Invalidate();
+ maVSWidth.StartSelection();
+ }
+ //modify end
+ }
+ if((iPos >= 1 && iPos <= 8) || (iPos == 9 && mbCustom)) //add
+ mrLinePropertyPanel.EndLineWidthPopupMode();
+ }
+ return( 0L );
+}
+
+
+
+
+IMPL_LINK(LineWidthControl, MFModifyHdl, void *, pControl)
+{
+ if(pControl == &maMFWidth)
+ {
+ if(maVSWidth.GetSelItem())
+ {
+ maVSWidth.SetSelItem(0);
+ maVSWidth.Format();
+ Invalidate();
+ maVSWidth.StartSelection();
+ }
+ long nTmp = static_cast<long>(maMFWidth.GetValue());
+ long nVal = LogicToLogic( nTmp, MAP_POINT, (MapUnit)meMapUnit );
+ sal_Int32 nNewWidth = (short)maMFWidth.Denormalize( nVal );
+ XLineWidthItem aWidthItem(nNewWidth);
+ mpBindings->GetDispatcher()->Execute(SID_ATTR_LINE_WIDTH, SFX_CALLMODE_RECORD, &aWidthItem, 0L);
+
+ mbColseByEdit = true;
+ mnTmpCusomWidth = nTmp;
+ /*for(sal_uInt16 i = 0; i < 8; i++)
+ {
+ if(nTmp == (sal_Int32)maVSWidth.GetItemData(i))
+ {
+ mbColseByEdit = false;
+ break;
+ }
+ }*/
+
+ }
+ return( 0L );
+}
+
+
+
+
+bool LineWidthControl::IsCloseByEdit()
+{
+ return mbColseByEdit;
+}
+
+
+
+
+long LineWidthControl::GetTmpCustomWidth()
+{
+ return mnTmpCusomWidth;
+}
+
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.hxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthControl.hxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,73 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "svx/sidebar/PopupControl.hxx"
+#include "LineWidthValueSet.hxx"
+#include <svl/poolitem.hxx>
+#include <vcl/fixed.hxx>
+#include <vcl/field.hxx>
+
+class SfxBindings;
+
+namespace svx { namespace sidebar {
+
+class LinePropertyPanel;
+
+class LineWidthControl
+ : public svx::sidebar::PopupControl
+{
+public:
+ LineWidthControl (Window* pParent, LinePropertyPanel& rPanel);
+ virtual ~LineWidthControl (void);
+
+ virtual void GetFocus();
+ virtual void Paint(const Rectangle& rect);
+
+ void SetWidthSelect( long lValue, bool bValuable, SfxMapUnit eMapUnit);
+ ValueSet& GetValueSet();
+ bool IsCloseByEdit();
+ long GetTmpCustomWidth();
+
+private:
+ LinePropertyPanel& mrLinePropertyPanel;
+ SfxBindings* mpBindings;
+ LineWidthValueSet maVSWidth;
+ FixedText maFTCus;
+ FixedText maFTWidth;
+ MetricField maMFWidth;
+ SfxMapUnit meMapUnit;
+ XubString* rStr;
+ XubString mstrPT; //
+ long mnCustomWidth;
+ bool mbCustom;
+ bool mbColseByEdit;
+ long mnTmpCusomWidth;
+ bool mbVSFocus;
+
+ Image maIMGCus;
+ Image maIMGCusGray;
+
+ void Initialize();
+ DECL_LINK(VSSelectHdl, void *);
+ DECL_LINK(MFModifyHdl, void *);
+};
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,87 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "LineWidthPopup.hxx"
+#include "LineWidthControl.hxx"
+#include "LinePropertyPanel.hxx"
+
+#include <unotools/viewoptions.hxx>
+
+#include <boost/bind.hpp>
+
+
+namespace svx { namespace sidebar {
+
+LineWidthPopup::LineWidthPopup (
+ Window* pParent,
+ const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator)
+ : Popup(
+ pParent,
+ rControlCreator,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Width")))
+{
+ SetPopupModeEndHandler(::boost::bind(&LineWidthPopup::PopupModeEndCallback, this));
+}
+
+
+
+
+LineWidthPopup::~LineWidthPopup (void)
+{
+}
+
+
+
+
+void LineWidthPopup::SetWidthSelect (long lValue, bool bValuable, SfxMapUnit eMapUnit)
+{
+ ProvideContainerAndControl();
+
+ LineWidthControl* pControl = dynamic_cast<LineWidthControl*>(mpControl.get());
+ if (pControl != NULL)
+ pControl->SetWidthSelect(lValue, bValuable, eMapUnit);
+}
+
+
+
+
+void LineWidthPopup::PopupModeEndCallback (void)
+{
+ LineWidthControl* pControl = dynamic_cast<LineWidthControl*>(mpControl.get());
+ if (pControl != NULL)
+ {
+ if (pControl->IsCloseByEdit())
+ {
+ SvtViewOptions aWinOpt( E_WINDOW, SIDEBAR_LINE_WIDTH_GLOBAL_VALUE );
+ ::com::sun::star::uno::Sequence < ::com::sun::star::beans::NamedValue > aSeq(1);
+ aSeq[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LineWidth") );
+ aSeq[0].Value <<= ::rtl::OUString(
+ String::CreateFromInt32(pControl->GetTmpCustomWidth()));
+ aWinOpt.SetUserData( aSeq );
+ }
+ }
+}
+
+
+
+} } // end of namespace svx::sidebar
+
+
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.hxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthPopup.hxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,51 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef _SVX_SIDEBAR_LINE_WIDTH_POPUP_HXX_
+#define _SVX_SIDEBAR_LINE_WIDTH_POPUP_HXX_
+
+#include "svx/sidebar/Popup.hxx"
+
+#include <svl/poolitem.hxx>
+
+#include <boost/function.hpp>
+
+
+namespace svx { namespace sidebar {
+
+class LineWidthPopup
+ : public Popup
+{
+public :
+ LineWidthPopup (
+ Window* pParent,
+ const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator);
+ virtual ~LineWidthPopup (void);
+
+ void SetWidthSelect (long lValue, bool bValuable, SfxMapUnit eMapUnit);
+
+private:
+ void PopupModeEndCallback (void);
+};
+
+} } // end of namespace svx::sidebar
+
+#endif
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,194 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "LineWidthValueSet.hxx"
+
+#include <i18npool/mslangid.hxx>
+
+namespace svx { namespace sidebar {
+
+
+LineWidthValueSet::LineWidthValueSet (
+ Window* pParent, const ResId& rResId)
+ : ValueSet( pParent, rResId ),
+ pVDev(NULL),
+ nSelItem(0),
+ bCusEnable(false)
+{
+ strUnit = new XubString[9];
+ SetColCount( 1 );
+ SetLineCount( 9);
+}
+
+
+
+
+LineWidthValueSet::~LineWidthValueSet (void)
+{
+ delete pVDev;
+ delete[] strUnit;
+}
+
+
+
+
+void LineWidthValueSet::SetUnit(XubString* str)
+{
+ for(int i = 0; i < 9; i++)
+ {
+ strUnit[i] = str[i];
+ }
+}
+
+
+
+void LineWidthValueSet::SetSelItem(sal_uInt16 nSel)
+{
+ nSelItem = nSel;
+ if(nSel == 0)
+ {
+ SelectItem(1); // ,false); // 'false' nut supported by AOO
+ SetNoSelection();
+ }
+ else
+ {
+ SelectItem(nSelItem);
+ GrabFocus();
+ }
+}
+
+
+
+
+sal_uInt16 LineWidthValueSet::GetSelItem()
+{
+ return nSelItem;
+}
+
+
+
+
+void LineWidthValueSet::SetImage(Image img)
+{
+ imgCus = img;
+}
+
+
+
+
+void LineWidthValueSet::SetCusEnable(bool bEnable)
+{
+ bCusEnable = bEnable;
+}
+
+
+
+
+void LineWidthValueSet::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ Rectangle aRect = rUDEvt.GetRect();
+ OutputDevice* pDev = rUDEvt.GetDevice();
+ sal_uInt16 nItemId = rUDEvt.GetItemId();
+
+ long nRectHeight = aRect.GetHeight();
+ long nRectWidth = aRect.GetWidth();
+ Point aBLPos = aRect.TopLeft();
+
+ //const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ //Color aBackColor(0,0,200);
+ //const Color aTextColor = rStyleSettings.GetFieldTextColor();
+ Font aOldFont = pDev->GetFont();
+ Color aOldColor = pDev->GetLineColor();
+ Color aOldFillColor = pDev->GetFillColor();
+
+ Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
+ Size aSize = aFont.GetSize();
+ aSize.Height() = nRectHeight*3/5;
+ aFont.SetSize( aSize );
+
+ Point aLineStart(aBLPos.X() + 5, aBLPos.Y() + ( nRectHeight - nItemId )/2);
+ Point aLineEnd(aBLPos.X() + nRectWidth * 7 / 9 - 10, aBLPos.Y() + ( nRectHeight - nItemId )/2);
+ if(nItemId == 9)
+ {
+ Point aImgStart(aBLPos.X() + 5, aBLPos.Y() + ( nRectHeight - 23 ) / 2);
+ pDev->DrawImage(aImgStart, imgCus);
+ // Point aStart(aImgStart.X() + 14 + 20 , aBLPos.Y() + nRectHeight/6);
+ Rectangle aStrRect = aRect;
+ aStrRect.Top() += nRectHeight/6;
+ aStrRect.Bottom() -= nRectHeight/6;
+ aStrRect.Left() += imgCus.GetSizePixel().Width() + 20;
+ if(bCusEnable)
+ aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
+ else
+ aFont.SetColor(GetSettings().GetStyleSettings().GetDisableColor());
+
+ pDev->SetFont(aFont);
+ pDev->DrawText(aStrRect, strUnit[ nItemId - 1 ], TEXT_DRAW_ENDELLIPSIS);
+ }
+ else
+ {
+ if( nSelItem == nItemId )
+ {
+ Color aBackColor(50,107,197);
+ Rectangle aBackRect = aRect;
+ aBackRect.Top() += 3;
+ aBackRect.Bottom() -= 2;
+ pDev->SetFillColor(aBackColor);
+ pDev->DrawRect(aBackRect);
+ }
+ else
+ {
+ pDev->SetFillColor( COL_TRANSPARENT );
+ pDev->DrawRect(aRect);
+ }
+
+ //draw text
+ if(nSelItem == nItemId )
+ aFont.SetColor(COL_WHITE);
+ else
+ aFont.SetColor(GetSettings().GetStyleSettings().GetFieldTextColor());
+ pDev->SetFont(aFont);
+ Point aStart(aBLPos.X() + nRectWidth * 7 / 9 , aBLPos.Y() + nRectHeight/6);
+ pDev->DrawText(aStart, strUnit[ nItemId - 1 ]); //can't set TEXT_DRAW_ENDELLIPSIS here ,or the text will disappear
+
+ //draw line
+ if( nSelItem == nItemId )
+ pDev->SetLineColor(COL_WHITE);
+ else
+ pDev->SetLineColor(GetSettings().GetStyleSettings().GetFieldTextColor());
+
+ for(sal_uInt16 i = 1; i <= nItemId; i++)
+ {
+ pDev->DrawLine(aLineStart,aLineEnd );
+ aLineStart.setY(aLineStart.getY() + 1);
+ aLineEnd.setY (aLineEnd.getY() + 1);
+ }
+ }
+
+ Invalidate( aRect );
+ pDev->SetLineColor(aOldColor);
+ pDev->SetFillColor(aOldFillColor);
+ pDev->SetFont(aOldFont);
+}
+
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.hxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.hxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/line/LineWidthValueSet.hxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,52 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include <svtools/valueset.hxx>
+
+#include <vcl/image.hxx>
+
+
+namespace svx { namespace sidebar {
+
+class LineWidthValueSet
+ : public ValueSet
+{
+public:
+ LineWidthValueSet (Window* pParent, const ResId& rResId);
+ virtual ~LineWidthValueSet (void);
+
+ void SetUnit(XubString* str);
+ void SetSelItem(sal_uInt16 nSel);
+ sal_uInt16 GetSelItem();
+ void SetImage(Image img);
+ void SetCusEnable(bool bEnable);
+
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+
+protected:
+ VirtualDevice* pVDev;
+ sal_uInt16 nSelItem;
+ XubString* strUnit;
+ Image imgCus;
+ bool bCusEnable;
+};
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorControl.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorControl.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorControl.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,228 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "precompiled_svx.hxx"
+
+#include "sidebar/ColorControl.hxx"
+#include "svx/svxids.hrc"
+#include "svx/drawitem.hxx"
+#include "svx/xtable.hxx"
+#include "svx/dialmgr.hxx"
+#include "svx/xflclit.hxx"
+#include <tools/resid.hxx>
+#include <sfx2/sidebar/Theme.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <vcl/floatwin.hxx>
+#include <unotools/pathoptions.hxx>
+#include <editeng/editrids.hrc>
+
+using ::sfx2::sidebar::Theme;
+
+namespace svx { namespace sidebar {
+
+namespace {
+ short GetItemId_Imp( ValueSet& rValueSet, const Color& rCol )
+ {
+ if(rCol == COL_AUTO)
+ return 0;
+
+ bool bFound = false;
+ sal_uInt16 nCount = rValueSet.GetItemCount();
+ sal_uInt16 n = 1;
+
+ while ( !bFound && n <= nCount )
+ {
+ Color aValCol = rValueSet.GetItemColor(n);
+
+ bFound = ( aValCol.GetRed() == rCol.GetRed()
+ && aValCol.GetGreen() == rCol.GetGreen()
+ && aValCol.GetBlue() == rCol.GetBlue() );
+
+ if ( !bFound )
+ n++;
+ }
+ return bFound ? n : -1;
+ }
+ class JustReleaseDeleter {public:
+ void operator() (XColorTable*) const {/* release but don't delete pointer */}
+ };
+ ::boost::shared_ptr<XColorTable> GetColorTable (void)
+ {
+ SfxObjectShell* pDocSh = SfxObjectShell::Current();
+ DBG_ASSERT(pDocSh!=NULL, "DocShell not found!");
+ if (pDocSh != NULL)
+ {
+ const SfxPoolItem* pItem = pDocSh->GetItem(SID_COLOR_TABLE);
+ if (pItem != NULL)
+ {
+ XColorTable* pTable = ((SvxColorTableItem*)pItem)->GetColorTable();
+ if (pTable != NULL)
+ return ::boost::shared_ptr<XColorTable>(pTable, JustReleaseDeleter());
+ }
+ }
+
+ return ::boost::shared_ptr<XColorTable>(new XColorTable(SvtPathOptions().GetPalettePath()));
+ }
+} // end of anonymous namespace
+
+
+
+
+ColorControl::ColorControl (
+ Window* pParent,
+ SfxBindings* pBindings,
+ const ResId& rControlResId,
+ const ResId& rValueSetResId,
+ const ::boost::function<Color(void)>& rColorGetter,
+ const ::boost::function<void(String&,Color)>& rColorSetter,
+ FloatingWindow* pFloatingWindow,
+ const sal_uInt32 nNoColorStringResId)
+ : PopupControl(pParent, rControlResId),
+ mpBindings(pBindings),
+ maVSColor(this, rValueSetResId),
+ mpFloatingWindow(pFloatingWindow),
+ msNoColorString(
+ nNoColorStringResId>0
+ ? String(SVX_RES(nNoColorStringResId))
+ : String()),
+ maColorGetter(rColorGetter),
+ maColorSetter(rColorSetter)
+{
+ FreeResource();
+}
+
+
+
+ColorControl::~ColorControl (void)
+{
+}
+
+
+
+
+void ColorControl::FillColors (void)
+{
+ ::boost::shared_ptr<XColorTable> pColorTable (GetColorTable());
+
+ if (pColorTable)
+ {
+ const long nColorCount (pColorTable->Count());
+ if (nColorCount <= 0)
+ return;
+ const sal_Int32 nColumnCount (ceil(sqrt(double(nColorCount))));
+ const sal_Int32 nRowCount (ceil(double(nColorCount)/nColumnCount));
+ maVSColor.SetColCount(nColumnCount);
+ maVSColor.SetLineCount(nRowCount);
+ const sal_Int32 nItemSize (15*12 / ::std::max<sal_Int32>(nColumnCount, nRowCount));
+ maVSColor.CalcWindowSizePixel(Size(nItemSize,nItemSize));
+ Link aLink = LINK(this, ColorControl, VSSelectHdl);
+ maVSColor.SetSelectHdl(aLink);
+ maVSColor.SetStyle(
+ (maVSColor.GetStyle()
+ | WB_TABSTOP | WB_ITEMBORDER | WB_NAMEFIELD// | WB_FLATVALUESET
+ | WB_NO_DIRECTSELECT | WB_MENUSTYLEVALUESET | WB_NO_DIRECTSELECT)
+ & ~WB_VSCROLL);
+
+ if (msNoColorString.Len() > 0)
+ {
+ maVSColor.SetStyle(maVSColor.GetStyle() | WB_NONEFIELD);
+ maVSColor.SetText(msNoColorString);
+ }
+
+ // Now, after all calls to SetStyle, we can change the
+ // background color.
+ maVSColor.SetBackground(Theme::GetWallpaper(Theme::Paint_DropDownBackground));
+
+ maVSColor.Clear();
+ XColorEntry* pEntry = NULL;
+ for (sal_Int32 nIndex=0; nIndex<nColorCount; ++nIndex)
+ {
+ pEntry = pColorTable->GetColor(nIndex);
+ maVSColor.InsertItem(nIndex+1, pEntry->GetColor(), pEntry->GetName() );
+ }
+ }
+
+ maVSColor.Show();
+}
+
+
+
+
+void ColorControl::GetFocus (void)
+{
+ maVSColor.GrabFocus();
+}
+
+
+
+
+void ColorControl::SetCurColorSelect (Color aCol, bool bAvailable)
+{
+ FillColors();
+ short nCol = GetItemId_Imp( maVSColor, aCol );
+ if(! bAvailable)
+ {
+ maVSColor.SetNoSelection();
+ return;
+ }
+
+ //if not found
+ if( nCol == -1)
+ {
+ maVSColor.SetNoSelection();
+ }
+ else
+ {
+ maVSColor.SelectItem( nCol );
+ }
+}
+
+
+
+
+IMPL_LINK(ColorControl, VSSelectHdl, void *, pControl)
+{
+ if(pControl == &maVSColor)
+ {
+ sal_uInt16 iPos = maVSColor.GetSelectItemId();
+ Color aColor = maVSColor.GetItemColor( iPos );
+
+ String aTmpStr = maVSColor.GetItemText( iPos );
+ if (aColor.GetColor() == 0
+ && aTmpStr.Equals(String::CreateFromAscii("")))
+ {
+ if (maColorGetter)
+ aColor = maColorGetter();
+ }
+ if (maColorSetter)
+ maColorSetter(aTmpStr, aColor);
+
+ if (mpFloatingWindow!=NULL && mpFloatingWindow->IsInPopupMode())
+ mpFloatingWindow->EndPopupMode();
+ }
+
+ return 0;
+}
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorPopup.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorPopup.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorPopup.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/tools/ColorPopup.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,60 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "sidebar/ColorPopup.hxx"
+#include "sidebar/ColorControl.hxx"
+
+
+namespace svx { namespace sidebar {
+
+ColorPopup::ColorPopup (
+ Window* pParent,
+ const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator)
+ : Popup(
+ pParent,
+ rControlCreator,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Color")))
+{
+}
+
+
+
+
+ColorPopup::~ColorPopup (void)
+{
+}
+
+
+
+
+void ColorPopup::SetCurrentColor (
+ const Color aCurrentColor,
+ const bool bIsColorAvailable)
+{
+ ProvideContainerAndControl();
+
+ ColorControl* pColorControl = dynamic_cast<ColorControl*>(mpControl.get());
+ if (pColorControl != NULL)
+ pColorControl->SetCurColorSelect(aCurrentColor, bIsColorAvailable);
+}
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/tools/Popup.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/tools/Popup.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/tools/Popup.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/tools/Popup.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,145 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "svx/sidebar/Popup.hxx"
+#include "svx/sidebar/PopupContainer.hxx"
+#include "svx/sidebar/PopupControl.hxx"
+
+#include <vcl/toolbox.hxx>
+
+
+namespace svx { namespace sidebar {
+
+Popup::Popup (
+ Window* pParent,
+ const ::boost::function<PopupControl*(PopupContainer*)>& rControlCreator,
+ const ::rtl::OUString& rsAccessibleName)
+ : mpControl(),
+ mpParent(pParent),
+ maControlCreator(rControlCreator),
+ maPopupModeEndCallback(),
+ msAccessibleName(rsAccessibleName),
+ mpContainer()
+{
+ OSL_ASSERT(mpParent!=NULL);
+ OSL_ASSERT(maControlCreator);
+}
+
+
+
+
+Popup::~Popup (void)
+{
+ mpControl.reset();
+ mpContainer.reset();
+}
+
+
+
+
+void Popup::Show (ToolBox& rToolBox)
+{
+ rToolBox.SetItemDown(rToolBox.GetCurItemId(), true);
+
+ ProvideContainerAndControl();
+ if ( ! (mpContainer && mpControl))
+ {
+ OSL_ASSERT(mpContainer);
+ OSL_ASSERT(mpControl);
+ return;
+ }
+
+ mpContainer->SetSizePixel(mpControl->GetOutputSizePixel());
+
+ const Point aPos (mpParent->OutputToScreenPixel(rToolBox.GetPosPixel()));
+ const Size aSize (rToolBox.GetSizePixel());
+ const Rectangle aRect (aPos, aSize);
+
+ mpContainer->StartPopupMode(
+ aRect,
+ FLOATWIN_POPUPMODE_NOFOCUSCLOSE|FLOATWIN_POPUPMODE_DOWN);
+ mpContainer->SetPopupModeFlags(
+ mpContainer->GetPopupModeFlags()
+ | FLOATWIN_POPUPMODE_NOAPPFOCUSCLOSE);
+
+ mpControl->GetFocus();
+}
+
+
+
+
+void Popup::Hide (void)
+{
+ if (mpContainer)
+ if (mpContainer->IsInPopupMode())
+ mpContainer->EndPopupMode();
+}
+
+
+
+
+void Popup::SetPopupModeEndHandler (const ::boost::function<void(void)>& rCallback)
+{
+ maPopupModeEndCallback = rCallback;
+ if (mpContainer)
+ mpContainer->SetPopupModeEndHdl(LINK(this, Popup, PopupModeEndHandler));
+}
+
+
+
+
+void Popup::ProvideContainerAndControl (void)
+{
+ if ( ! (mpContainer && mpControl)
+ && mpParent!=NULL
+ && maControlCreator)
+ {
+ CreateContainerAndControl();
+ }
+}
+
+
+
+
+void Popup::CreateContainerAndControl (void)
+{
+ mpContainer.reset(new PopupContainer(mpParent));
+ mpContainer->SetAccessibleName(msAccessibleName);
+ if (maPopupModeEndCallback)
+ mpContainer->SetPopupModeEndHdl(LINK(this, Popup, PopupModeEndHandler));
+ mpContainer->SetBorderStyle(mpContainer->GetBorderStyle() | WINDOW_BORDER_MENU);
+
+ mpControl.reset(maControlCreator(mpContainer.get()));
+}
+
+
+
+
+IMPL_LINK(Popup, PopupModeEndHandler, void*, EMPTYARG)
+{
+ if (maPopupModeEndCallback)
+ maPopupModeEndCallback();
+ return 0;
+}
+
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupContainer.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupContainer.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupContainer.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupContainer.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,57 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "svx/sidebar/PopupContainer.hxx"
+#include <sfx2/sidebar/Theme.hxx>
+#include <vcl/gradient.hxx>
+
+namespace svx { namespace sidebar {
+
+PopupContainer::PopupContainer (Window* pParent)
+ : FloatingWindow(pParent, WB_SYSTEMWINDOW | WB_3DLOOK) // | WB_POPUP_FOCUSWIN)
+{
+}
+
+
+
+
+PopupContainer::~PopupContainer (void)
+{
+}
+
+
+
+
+long PopupContainer::Notify (NotifyEvent& rEvent)
+{
+ if (rEvent.GetType() == EVENT_LOSEFOCUS)
+ {
+ if ( ! HasChildPathFocus(true))
+ {
+ EndPopupMode();
+ }
+ }
+
+ return FloatingWindow::Notify(rEvent);
+}
+
+
+} } // end of namespace svx::sidebar
Added: openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupControl.cxx?rev=1452760&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupControl.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/tools/PopupControl.cxx Tue Mar 5 12:17:09 2013
@@ -0,0 +1,62 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "svx/sidebar/PopupControl.hxx"
+#include <sfx2/sidebar/Theme.hxx>
+#include <vcl/gradient.hxx>
+
+using ::sfx2::sidebar::Theme;
+
+namespace svx { namespace sidebar {
+
+PopupControl::PopupControl (
+ Window* pParent,
+ const ResId& rResId)
+ : Control( pParent,rResId)
+{
+ EnableChildTransparentMode(true);
+ SetControlBackground();
+
+ SetBackground(Theme::GetWallpaper(Theme::Paint_DropDownBackground));
+}
+
+
+
+
+PopupControl::~PopupControl (void)
+{
+}
+
+
+
+
+void PopupControl::Paint (const Rectangle& rBox)
+{
+ Control::Paint(rBox);
+
+ // The background is taken care of by setting the background color
+ // in the constructor. Here we just paint the border.
+ SetFillColor();
+ SetLineColor(Theme::GetColor(Theme::Color_DropDownBorder));
+ DrawRect(Rectangle(Point(0,0), GetOutputSizePixel()));
+}
+
+} } // end of namespace svx::sidebar