You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2013/03/08 13:43:18 UTC
svn commit: r1454351 - in /openoffice/branches/sidebar/main/svx:
Library_svx.mk Package_inc.mk inc/svx/sidebar/ValueSetWithTextControl.hxx
source/sidebar/tools/ValueSetWithTextControl.cxx
Author: orw
Date: Fri Mar 8 12:43:17 2013
New Revision: 1454351
URL: http://svn.apache.org/r1454351
Log:
#121420# - new svx::sidebar::ValueSetWithTextControl - specialized <ValueSet> class: one-columned, image+text or text+text
Added:
openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ValueSetWithTextControl.hxx
openoffice/branches/sidebar/main/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
Modified:
openoffice/branches/sidebar/main/svx/Library_svx.mk
openoffice/branches/sidebar/main/svx/Package_inc.mk
Modified: openoffice/branches/sidebar/main/svx/Library_svx.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/Library_svx.mk?rev=1454351&r1=1454350&r2=1454351&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/Library_svx.mk (original)
+++ openoffice/branches/sidebar/main/svx/Library_svx.mk Fri Mar 8 12:43:17 2013
@@ -191,6 +191,7 @@ $(eval $(call gb_Library_add_exception_o
svx/source/sidebar/tools/PopupControl \
svx/source/sidebar/tools/PopupContainer \
svx/source/sidebar/tools/Popup \
+ svx/source/sidebar/tools/ValueSetWithTextControl \
svx/source/stbctrls/pszctrl \
svx/source/stbctrls/insctrl \
svx/source/stbctrls/selctrl \
Modified: openoffice/branches/sidebar/main/svx/Package_inc.mk
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/Package_inc.mk?rev=1454351&r1=1454350&r2=1454351&view=diff
==============================================================================
--- openoffice/branches/sidebar/main/svx/Package_inc.mk (original)
+++ openoffice/branches/sidebar/main/svx/Package_inc.mk Fri Mar 8 12:43:17 2013
@@ -560,4 +560,5 @@ $(eval $(call gb_Package_add_file,svx_in
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/Popup.hxx,svx/sidebar/Popup.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/PopupContainer.hxx,svx/sidebar/PopupContainer.hxx))
$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/PopupControl.hxx,svx/sidebar/PopupControl.hxx))
+$(eval $(call gb_Package_add_file,svx_inc,inc/svx/sidebar/ValueSetWithTextControl.hxx,svx/sidebar/ValueSetWithTextControl.hxx))
Added: openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ValueSetWithTextControl.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ValueSetWithTextControl.hxx?rev=1454351&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ValueSetWithTextControl.hxx (added)
+++ openoffice/branches/sidebar/main/svx/inc/svx/sidebar/ValueSetWithTextControl.hxx Fri Mar 8 12:43:17 2013
@@ -0,0 +1,100 @@
+/**************************************************************
+ *
+ * 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_VALUESETWITHTEXT_CONTROL_HXX_
+#define _SVX_SIDEBAR_VALUESETWITHTEXT_CONTROL_HXX_
+
+#include "svx/svxdllapi.h"
+
+#include <svtools/valueset.hxx>
+
+#include <vcl/image.hxx>
+
+#include <vector>
+
+namespace svx { namespace sidebar {
+
+/** Specialization of class <ValueSet>.
+ This specialization allows is a one-columned ValueSet which allow
+ items containing an image and a text or a text and a second text.
+
+ Especially, used for sidebar related controls.
+*/
+class SVX_DLLPUBLIC ValueSetWithTextControl : public ValueSet
+{
+public:
+ // control type of specialized <ValueSet>:
+ // - image + text
+ // - text + text
+ enum tControlType
+ {
+ IMAGE_TEXT,
+ TEXT_TEXT
+ };
+
+ ValueSetWithTextControl(
+ const tControlType eControlType,
+ Window* pParent,
+ const ResId& rResId);
+
+ virtual ~ValueSetWithTextControl(void);
+
+ // add item for control type IMAGE_TEXT
+ // if control type does not match IMAGE_TEXT no item is added.
+ // @param pSelectedItemImage
+ // selection item image is optional. if not provided, it is the same as the image item
+ // @param pItemHelpText
+ // help text is optional. if not provided, it is the same as the item text
+ void AddItem(
+ const Image& rItemImage,
+ const Image* pSelectedItemImage,
+ const XubString& rItemText,
+ const XubString* pItemHelpText );
+
+ // add item for control type TEXT_TEXT
+ // if control type does not match TEXT_TEXT no item is added.
+ // @param pItemHelpText
+ // help text is optional. if not provided, it is the same as the item text
+ void AddItem(
+ const XubString& rItemText,
+ const XubString& rItemText2,
+ const XubString* pItemHelpText );
+
+ virtual void UserDraw( const UserDrawEvent& rUDEvt );
+
+private:
+ struct ValueSetWithTextItem
+ {
+ Image maItemImage;
+ Image maSelectedItemImage;
+ XubString maItemText;
+ XubString maItemText2;
+ };
+
+ typedef ::std::vector< ValueSetWithTextItem > tItemList;
+
+ const tControlType meControlType;
+ tItemList maItems;
+};
+
+} } // end of namespace svx::sidebar
+
+#endif
Added: openoffice/branches/sidebar/main/svx/source/sidebar/tools/ValueSetWithTextControl.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/sidebar/main/svx/source/sidebar/tools/ValueSetWithTextControl.cxx?rev=1454351&view=auto
==============================================================================
--- openoffice/branches/sidebar/main/svx/source/sidebar/tools/ValueSetWithTextControl.cxx (added)
+++ openoffice/branches/sidebar/main/svx/source/sidebar/tools/ValueSetWithTextControl.cxx Fri Mar 8 12:43:17 2013
@@ -0,0 +1,174 @@
+/**************************************************************
+ *
+ * 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/ValueSetWithTextControl.hxx"
+
+#include <sfx2/sidebar/Theme.hxx>
+
+#include <i18npool/mslangid.hxx>
+
+namespace svx { namespace sidebar {
+
+ValueSetWithTextControl::ValueSetWithTextControl(
+ const tControlType eControlType,
+ Window* pParent,
+ const ResId& rResId)
+ : ValueSet( pParent, rResId )
+ , meControlType( eControlType )
+ , maItems()
+{
+ SetColCount( 1 );
+}
+
+ValueSetWithTextControl::~ValueSetWithTextControl(void)
+{
+}
+
+void ValueSetWithTextControl::AddItem(
+ const Image& rItemImage,
+ const Image* pSelectedItemImage,
+ const XubString& rItemText,
+ const XubString* pItemHelpText )
+{
+ if ( meControlType != IMAGE_TEXT )
+ {
+ return;
+ }
+
+ ValueSetWithTextItem aItem;
+ aItem.maItemImage = rItemImage;
+ aItem.maSelectedItemImage = (pSelectedItemImage != 0)
+ ? *pSelectedItemImage
+ : rItemImage;
+ aItem.maItemText = rItemText;
+
+ maItems.push_back( aItem );
+
+ InsertItem( maItems.size() );
+ SetItemText( maItems.size(),
+ (pItemHelpText != 0) ? *pItemHelpText : rItemText );
+}
+
+void ValueSetWithTextControl::AddItem(
+ const XubString& rItemText,
+ const XubString& rItemText2,
+ const XubString* pItemHelpText )
+{
+ if ( meControlType != TEXT_TEXT )
+ {
+ return;
+ }
+
+ ValueSetWithTextItem aItem;
+ aItem.maItemText = rItemText;
+ aItem.maItemText2 = rItemText2;
+
+ maItems.push_back( aItem );
+
+ InsertItem( maItems.size() );
+ SetItemText( maItems.size(),
+ (pItemHelpText != 0) ? *pItemHelpText : rItemText );
+}
+
+void ValueSetWithTextControl::UserDraw( const UserDrawEvent& rUDEvt )
+{
+ const Rectangle aRect = rUDEvt.GetRect();
+ OutputDevice* pDev = rUDEvt.GetDevice();
+ pDev->Push( PUSH_ALL );
+ const sal_uInt16 nItemId = rUDEvt.GetItemId();
+
+ const long nRectHeight = aRect.GetHeight();
+ const Point aBLPos = aRect.TopLeft();
+
+ Font aFont(OutputDevice::GetDefaultFont(DEFAULTFONT_UI_SANS, MsLangId::getSystemLanguage(), DEFAULTFONT_FLAGS_ONLYONE));
+ {
+ Size aSize = aFont.GetSize();
+ aSize.Height() = (nRectHeight*4)/9;
+ aFont.SetSize( aSize );
+ }
+
+ {
+ //draw backgroud
+ if ( GetSelectItemId() == nItemId )
+ {
+ Rectangle aBackRect = aRect;
+ aBackRect.Top() += 3;
+ aBackRect.Bottom() -= 2;
+ pDev->SetFillColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_Highlight ) );
+ pDev->DrawRect(aBackRect);
+ }
+ else
+ {
+ pDev->SetFillColor( COL_TRANSPARENT );
+ pDev->DrawRect(aRect);
+ }
+
+ //draw image + text resp. text + text
+ Image* pImage = 0;
+ if ( GetSelectItemId() == nItemId )
+ {
+ aFont.SetColor( sfx2::sidebar::Theme::GetColor( sfx2::sidebar::Theme::Color_HighlightText ) );
+ pImage = &maItems[nItemId-1].maSelectedItemImage;
+ }
+ else
+ {
+ aFont.SetColor( GetSettings().GetStyleSettings().GetFieldTextColor() );
+ pImage = &maItems[nItemId-1].maItemImage;
+ }
+
+ Rectangle aStrRect = aRect;
+ aStrRect.Top() += nRectHeight/4;
+ aStrRect.Bottom() -= nRectHeight/4;
+
+ switch ( meControlType )
+ {
+ case IMAGE_TEXT:
+ {
+ Point aImgStart(
+ aBLPos.X() + 4,
+ aBLPos.Y() + ( ( nRectHeight - pImage->GetSizePixel().Height() ) / 2 ) );
+ pDev->DrawImage( aImgStart, *pImage );
+
+ aStrRect.Left() += pImage->GetSizePixel().Width() + 12;
+ pDev->SetFont(aFont);
+ pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText, TEXT_DRAW_ENDELLIPSIS);
+ }
+ break;
+ case TEXT_TEXT:
+ {
+ const long nRectWidth = aRect.GetWidth();
+ aStrRect.Left() += 8;
+ aStrRect.Right() -= (nRectWidth*2)/3;
+ pDev->SetFont(aFont);
+ pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText, TEXT_DRAW_ENDELLIPSIS);
+ aStrRect.Left() += nRectWidth/3;
+ aStrRect.Right() += (nRectWidth*2)/3;
+ pDev->DrawText(aStrRect, maItems[nItemId-1].maItemText2, TEXT_DRAW_ENDELLIPSIS);
+ }
+ break;
+ }
+ }
+
+ Invalidate( aRect );
+ pDev->Pop();
+}
+
+} } // end of namespace svx::sidebar