cui/source/dialogs/cuicharmap.cxx | 35 ++++++++++-- cui/source/inc/cuicharmap.hxx | 4 + cui/uiconfig/ui/specialcharacters.ui | 27 +++++---- svx/inc/svx/charmap.hxx | 5 + svx/source/dialog/charmap.cxx | 102 +++++++++++++++++++++-------------- 5 files changed, 117 insertions(+), 56 deletions(-)
New commits: commit b43bd72c7d81b58c5f58a5c29fab7982878b5f63 Author: Caolán McNamara <[email protected]> Date: Wed Jan 16 11:51:11 2013 +0000 Resolves: fdo#59182 make the special character dialog behave squashed combo of four commits to fix fdo#59182 Related: fdo#59182 stop SvxShowCharSet resizing itself instead of resizing itself when given a size, leading to lots of flicker as the widget fights the layout, instead accept the given size, center the drawing in that area, and tweak the cell highlight drawing code to fill that extra gap space when edge cells are selected (cherry picked from commit 3c8d3ef10267fb0a50686f49c15a3e4ab35503d1) Related: fdo#59182 make SvxShowText::GetOptimalSize match its SetFont logic SetFont takes the window size to determine the best font size, so reverse that SetFont logic to get the desired optimal window size. (cherry picked from commit 463f2d4fe211e991d551be67be74cf2090afdb7e) Resolves: fdo#59182 make the special character dialog behave lock down the sizes of the widgets which depend on the (variable) font in terms of widgets which are invariant so that they don't jump around to their optimal sizes as the selected font changes. (cherry picked from commit f1088250485fa91b4131102c5275e73653bc0c2c) use the theme width for the scrollbar, not a random 16 pixels (cherry picked from commit 26af997c55106fd067b32caaceedde3f2c10c1dc) 0d2e35a780552ca52aec20809bcb77d37b6a1bfb 65ea24adb43f9faa974025b6db1c35766b577cd7 e823124e8f156099e5b1708afa5b830153fcce3e Change-Id: Iee0b44c0939cf32284907ad1fcd57e2e722837d4 Reviewed-on: https://gerrit.libreoffice.org/1716 Reviewed-by: Noel Power <[email protected]> Tested-by: Noel Power <[email protected]> diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index f457ba3..714fec4 100644 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -59,8 +59,15 @@ SvxCharacterMap::SvxCharacterMap( Window* pParent, sal_Bool bOne_, const SfxItem m_pFontLB->SetStyle(m_pFontLB->GetStyle() | WB_SORT); get(m_pSubsetText, "subsetft"); get(m_pSubsetLB, "subsetlb"); + //lock the size request of this widget to the width of all possible entries + fillAllSubsets(*m_pSubsetLB); + m_pSubsetLB->set_width_request(m_pSubsetLB->get_preferred_size().Width()); get(m_pCharCodeText, "charcodeft"); + //lock the size request of this widget to the width of the original .ui string + m_pCharCodeText->set_width_request(m_pCharCodeText->get_preferred_size().Width()); get(m_pSymbolText, "symboltext"); + //lock the size request of this widget to double the height of the label + m_pShowText->set_height_request(m_pSymbolText->get_preferred_size().Height() * 3); SFX_ITEMSET_ARG( pSet, pItem, SfxBoolItem, FN_PARAM_1, sal_False ); if ( pItem ) @@ -241,6 +248,16 @@ void SvxShowText::SetFont( const Font& rFont ) Invalidate(); } +Size SvxShowText::GetOptimalSize(WindowSizeType eType) const +{ + if (eType == WINDOWSIZE_MAXIMUM) + return Control::GetOptimalSize(WINDOWSIZE_MAXIMUM); + const Font &rFont = GetFont(); + const Size rFontSize = rFont.GetSize(); + long nWinHeight = LogicToPixel(rFontSize).Height() * 2; + return Size( GetTextWidth( GetText() ) + 2 * 12, nWinHeight ); +} + void SvxShowText::Resize() { Control::Resize(); @@ -367,6 +384,18 @@ IMPL_LINK_NOARG(SvxCharacterMap, OKHdl) return 0; } +void SvxCharacterMap::fillAllSubsets(ListBox &rListBox) +{ + SubsetMap aAll(NULL); + rListBox.Clear(); + bool bFirst = true; + while (const Subset *s = aAll.GetNextSubset(bFirst)) + { + rListBox.InsertEntry( s->GetName() ); + bFirst = false; + } +} + // ----------------------------------------------------------------------- IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl) @@ -390,6 +419,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl) // TODO: get info from the Font once it provides it delete pSubsetMap; pSubsetMap = NULL; + m_pSubsetLB->Clear(); sal_Bool bNeedSubset = (aFont.GetCharSet() != RTL_TEXTENCODING_SYMBOL); if( bNeedSubset ) @@ -399,7 +429,6 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl) pSubsetMap = new SubsetMap( &aFontCharMap ); // update subset listbox for new font's unicode subsets - m_pSubsetLB->Clear(); // TODO: is it worth to improve the stupid linear search? bool bFirst = true; const Subset* s; @@ -416,8 +445,8 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl) bNeedSubset = sal_False; } - m_pSubsetText->Show( bNeedSubset); - m_pSubsetLB->Show( bNeedSubset); + m_pSubsetText->Enable(bNeedSubset); + m_pSubsetLB->Enable(bNeedSubset); return 0; } diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx index e2e8e1c..6729194 100644 --- a/cui/source/inc/cuicharmap.hxx +++ b/cui/source/inc/cuicharmap.hxx @@ -49,6 +49,8 @@ public: virtual void Resize(); + virtual Size GetOptimalSize(WindowSizeType eType) const; + protected: virtual void Paint( const Rectangle& ); @@ -90,6 +92,8 @@ private: DECL_LINK(CharPreSelectHdl, void *); DECL_LINK(DeleteHdl, void *); + void fillAllSubsets(ListBox &rListBox); + public: SvxCharacterMap( Window* pParent, sal_Bool bOne=sal_True, const SfxItemSet* pSet=0 ); ~SvxCharacterMap(); diff --git a/cui/uiconfig/ui/specialcharacters.ui b/cui/uiconfig/ui/specialcharacters.ui index 94287d8..03e3eae 100644 --- a/cui/uiconfig/ui/specialcharacters.ui +++ b/cui/uiconfig/ui/specialcharacters.ui @@ -5,7 +5,6 @@ <property name="can_focus">False</property> <property name="border_width">5</property> <property name="title" translatable="yes">Special Characters</property> - <property name="resizable">False</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -19,12 +18,10 @@ <child> <object class="GtkButton" id="ok"> <property name="label">gtk-ok</property> - <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="has_default">True</property> <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> <property name="use_stock">True</property> </object> <packing> @@ -36,11 +33,9 @@ <child> <object class="GtkButton" id="cancel"> <property name="label">gtk-cancel</property> - <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> <property name="use_stock">True</property> <property name="xalign">0.50999999046325684</property> </object> @@ -53,11 +48,9 @@ <child> <object class="GtkButton" id="help"> <property name="label">gtk-help</property> - <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> <property name="use_stock">True</property> </object> <packing> @@ -69,11 +62,9 @@ <child> <object class="GtkButton" id="delete"> <property name="label">gtk-delete</property> - <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> - <property name="use_action_appearance">False</property> <property name="use_stock">True</property> <property name="image_position">bottom</property> </object> @@ -100,12 +91,15 @@ <object class="GtkGrid" id="grid1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <property name="row_spacing">6</property> <property name="column_spacing">6</property> <child> <object class="GtkGrid" id="grid2"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> <property name="column_spacing">6</property> <child> <object class="GtkLabel" id="fontft"> @@ -137,6 +131,7 @@ <object class="GtkComboBox" id="fontlb"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> </object> <packing> <property name="left_attach">1</property> @@ -149,6 +144,7 @@ <object class="GtkComboBox" id="subsetlb"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> </object> <packing> <property name="left_attach">3</property> @@ -169,11 +165,14 @@ <object class="GtkGrid" id="grid3"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> <child> <object class="GtkLabel" id="charcodeft"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">U+0020(32)</property> + <property name="hexpand">True</property> + <property name="label"> U+FFFF(65535) </property> </object> <packing> <property name="left_attach">0</property> @@ -212,6 +211,8 @@ <property name="height_request">250</property> <property name="visible">True</property> <property name="can_focus">True</property> + <property name="hexpand">True</property> + <property name="vexpand">True</property> </object> <packing> <property name="left_attach">0</property> @@ -225,7 +226,7 @@ </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">0</property> </packing> @@ -239,6 +240,7 @@ <object class="GtkLabel" id="symboltext"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="valign">center</property> <property name="label" translatable="yes">Characters:</property> </object> <packing> @@ -251,6 +253,7 @@ <object class="cuilo:SvxShowText" id="showtext"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="valign">center</property> </object> <packing> <property name="expand">False</property> @@ -267,7 +270,7 @@ </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> diff --git a/svx/inc/svx/charmap.hxx b/svx/inc/svx/charmap.hxx index a244f3a..8f1ff76 100644 --- a/svx/inc/svx/charmap.hxx +++ b/svx/inc/svx/charmap.hxx @@ -109,14 +109,14 @@ private: ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccessible; long nX; long nY; + long m_nXGap; + long m_nYGap; sal_Bool bDrag; sal_Int32 nSelectedIndex; FontCharMap maFontCharMap; ScrollBar aVscrollSB; - Size aOrigSize; - Point aOrigPos; private: void DrawChars_Impl( int n1, int n2); @@ -126,6 +126,7 @@ private: DECL_LINK(VscrollHdl, void *); void init(); + Rectangle getGridRectangle(const Point &rPointUL, const Size &rOutputSize); }; #endif diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx index 42b6417..7c5d971 100644 --- a/svx/source/dialog/charmap.cxx +++ b/svx/source/dialog/charmap.cxx @@ -54,8 +54,6 @@ sal_uInt32& SvxShowCharSet::getSelectedChar() // class SvxShowCharSet ================================================== -#define SBWIDTH 16 - SvxShowCharSet::SvxShowCharSet(Window* pParent, const ResId& rResId) : Control(pParent, rResId) , m_pAccessible(NULL) @@ -77,9 +75,8 @@ SvxShowCharSet::SvxShowCharSet(Window* pParent) void SvxShowCharSet::init() { nSelectedIndex = -1; // TODO: move into init list when it is no longer static - - aOrigSize = GetOutputSizePixel(); - aOrigPos = GetPosPixel(); + m_nXGap = 0; + m_nYGap = 0; SetStyle( GetStyle() | WB_CLIPCHILDREN ); aVscrollSB.SetScrollHdl( LINK( this, SvxShowCharSet, VscrollHdl ) ); @@ -91,11 +88,7 @@ void SvxShowCharSet::init() void SvxShowCharSet::Resize() { - aOrigSize = GetOutputSizePixel(); - aOrigPos = GetPosPixel(); - Control::Resize(); - SetFont(GetFont()); //force recalculation of correct fontsize } @@ -252,14 +245,14 @@ inline Point SvxShowCharSet::MapIndexToPixel( int nIndex ) const const int nBase = FirstInView(); int x = ((nIndex - nBase) % COLUMN_COUNT) * nX; int y = ((nIndex - nBase) / COLUMN_COUNT) * nY; - return Point( x, y ); + return Point( x + m_nXGap, y + m_nYGap ); } // ----------------------------------------------------------------------------- int SvxShowCharSet::PixelToMapIndex( const Point& point) const { int nBase = FirstInView(); - return (nBase + (point.X()/nX) + (point.Y()/nY) * COLUMN_COUNT); + return (nBase + ((point.X() - m_nXGap)/nX) + ((point.Y() - m_nYGap)/nY) * COLUMN_COUNT); } // ----------------------------------------------------------------------- @@ -342,7 +335,37 @@ void SvxShowCharSet::DeSelect() { DrawChars_Impl(nSelectedIndex,nSelectedIndex); } -// ----------------------------------------------------------------------- + +// stretch a grid rectangle if its at the edge to fill unused space +Rectangle SvxShowCharSet::getGridRectangle(const Point &rPointUL, const Size &rOutputSize) +{ + long x = rPointUL.X() - 1; + long y = rPointUL.Y() - 1; + Point aPointUL(x+1, y+1); + Size aGridSize(nX-1, nY-1); + + long nXDistFromLeft = x - m_nXGap; + if (nXDistFromLeft <= 1) + { + aPointUL.X() = 1; + aGridSize.Width() += m_nXGap + nXDistFromLeft; + } + long nXDistFromRight = rOutputSize.Width() - m_nXGap - nX - x; + if (nXDistFromRight <= 1) + aGridSize.Width() += m_nXGap + nXDistFromRight; + + long nXDistFromTop = y - m_nYGap; + if (nXDistFromTop <= 1) + { + aPointUL.Y() = 1; + aGridSize.Height() += m_nYGap + nXDistFromTop; + } + long nXDistFromBottom = rOutputSize.Height() - m_nYGap - nY - y; + if (nXDistFromBottom <= 1) + aGridSize.Height() += m_nYGap + nXDistFromBottom; + + return Rectangle(aPointUL, aGridSize); +} void SvxShowCharSet::DrawChars_Impl( int n1, int n2 ) { @@ -350,14 +373,14 @@ void SvxShowCharSet::DrawChars_Impl( int n1, int n2 ) return; Size aOutputSize = GetOutputSizePixel(); - if( aVscrollSB.IsVisible() ) - aOutputSize.setWidth( aOutputSize.Width() - SBWIDTH ); + if (aVscrollSB.IsVisible()) + aOutputSize.Width() -= aVscrollSB.GetOptimalSize(WINDOWSIZE_PREFERRED).Width(); int i; for ( i = 1; i < COLUMN_COUNT; ++i ) - DrawLine( Point( nX * i, 0 ), Point( nX * i, aOutputSize.Height() ) ); + DrawLine( Point( nX * i + m_nXGap, 0 ), Point( nX * i + m_nXGap, aOutputSize.Height() ) ); for ( i = 1; i < ROW_COUNT; ++i ) - DrawLine( Point( 0, nY * i ), Point( aOutputSize.Width(), nY * i ) ); + DrawLine( Point( 0, nY * i + m_nYGap ), Point( aOutputSize.Width(), nY * i + m_nYGap) ); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); const Color aWindowTextColor( rStyleSettings.GetFieldTextColor() ); @@ -427,7 +450,7 @@ void SvxShowCharSet::DrawChars_Impl( int n1, int n2 ) if( HasFocus() ) { SetFillColor( aHighlightColor ); - DrawRect( Rectangle( aPointUL, Size(nX-1,nY-1) ) ); + DrawRect( getGridRectangle(aPointUL, aOutputSize) ); SetTextColor( aHighlightTextColor ); DrawText( aPointTxTy, aCharStr ); @@ -435,7 +458,7 @@ void SvxShowCharSet::DrawChars_Impl( int n1, int n2 ) else { SetFillColor( aFaceColor ); - DrawRect( Rectangle( aPointUL, Size( nX-1, nY-1) ) ); + DrawRect( getGridRectangle(aPointUL, aOutputSize) ); SetLineColor( aLightColor ); DrawLine( aPointUL, Point( x+nX-1, y+1) ); @@ -497,42 +520,40 @@ void SvxShowCharSet::SetFont( const Font& rFont ) if( nSelectedIndex >= 0 ) getSelectedChar() = maFontCharMap.GetCharFromIndex( nSelectedIndex ); + Size aSize = GetOutputSizePixel(); + long nSBWidth = aVscrollSB.GetOptimalSize(WINDOWSIZE_PREFERRED).Width(); + aSize.Width() -= nSBWidth; + Font aFont = rFont; aFont.SetWeight( WEIGHT_LIGHT ); aFont.SetAlign( ALIGN_TOP ); - int nFontHeight = (aOrigSize.Height() - 5) * 2 / (3 * ROW_COUNT); + int nFontHeight = (aSize.Height() - 5) * 2 / (3 * ROW_COUNT); aFont.SetSize( PixelToLogic( Size( 0, nFontHeight ) ) ); aFont.SetTransparent( sal_True ); Control::SetFont( aFont ); GetFontCharMap( maFontCharMap ); - // hide scrollbar when there is nothing to scroll - sal_Bool bNeedVscroll = (maFontCharMap.GetCharCount() > ROW_COUNT*COLUMN_COUNT); + nX = aSize.Width() / COLUMN_COUNT; + nY = aSize.Height() / ROW_COUNT; - nX = (aOrigSize.Width() - (bNeedVscroll ? SBWIDTH : 0)) / COLUMN_COUNT; - nY = aOrigSize.Height() / ROW_COUNT; - - if( bNeedVscroll) - { - aVscrollSB.setPosSizePixel( nX * COLUMN_COUNT, 0, SBWIDTH, nY * ROW_COUNT ); - aVscrollSB.SetRangeMin( 0 ); - int nLastRow = (maFontCharMap.GetCharCount() - 1 + COLUMN_COUNT) / COLUMN_COUNT; - aVscrollSB.SetRangeMax( nLastRow ); - aVscrollSB.SetPageSize( ROW_COUNT-1 ); - aVscrollSB.SetVisibleSize( ROW_COUNT ); - } + aVscrollSB.setPosSizePixel( aSize.Width(), 0, nSBWidth, aSize.Height() ); + aVscrollSB.SetRangeMin( 0 ); + int nLastRow = (maFontCharMap.GetCharCount() - 1 + COLUMN_COUNT) / COLUMN_COUNT; + aVscrollSB.SetRangeMax( nLastRow ); + aVscrollSB.SetPageSize( ROW_COUNT-1 ); + aVscrollSB.SetVisibleSize( ROW_COUNT ); // restore last selected unicode int nMapIndex = maFontCharMap.GetIndexFromChar( getSelectedChar() ); SelectIndex( nMapIndex ); + aVscrollSB.Show(); + // rearrange CharSet element in sync with nX- and nY-multiples - Size aNewSize( nX * COLUMN_COUNT + (bNeedVscroll ? SBWIDTH : 0), nY * ROW_COUNT ); - Point aNewPos = aOrigPos + Point( (aOrigSize.Width() - aNewSize.Width()) / 2, 0 ); - SetPosPixel( aNewPos ); - SetOutputSizePixel( aNewSize ); + Size aDrawSize(nX * COLUMN_COUNT, nY * ROW_COUNT); + m_nXGap = (aSize.Width() - aDrawSize.Width()) / 2; + m_nYGap = (aSize.Height() - aDrawSize.Height()) / 2; - aVscrollSB.Show( bNeedVscroll ); Invalidate(); } @@ -589,7 +610,10 @@ void SvxShowCharSet::SelectIndex( int nNewIndex, sal_Bool bFocus ) Point aOldPixel = MapIndexToPixel( nSelectedIndex ); aOldPixel.Move( +1, +1); - DrawRect( Rectangle( aOldPixel, Size( nX-1, nY-1 ) ) ); + Size aOutputSize = GetOutputSizePixel(); + if (aVscrollSB.IsVisible()) + aOutputSize.Width() -= aVscrollSB.GetOptimalSize(WINDOWSIZE_PREFERRED).Width(); + DrawRect( getGridRectangle(aOldPixel, aOutputSize) ); SetLineColor( aLineCol ); SetFillColor( aFillCol );
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
