diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-24 17:59:28 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-11-24 18:39:08 +0100 |
commit | f2931c64d804bf63970bdb9fedf5e57f79a7a3a7 (patch) | |
tree | 3053dd15c0c830777bbfab40ffd648529c7405ab /sc | |
parent | c497ae0ded79422ec54ff8677e8a7c36351a7aef (diff) |
ManageNames: moving the header separator now updates the table too
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/namemgrtable.hxx | 2 | ||||
-rw-r--r-- | sc/source/ui/namedlg/namemgrtable.cxx | 64 |
2 files changed, 66 insertions, 0 deletions
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx index 2795a7e2e49d..b95002ee7d53 100644 --- a/sc/source/ui/inc/namemgrtable.hxx +++ b/sc/source/ui/inc/namemgrtable.hxx @@ -77,6 +77,8 @@ public: void GetCurrentLine(ScRangeNameLine& rLine); bool IsMultiSelection(); std::vector<ScRangeNameLine> GetSelectedEntries(); + + DECL_LINK( HeaderEndDragHdl, void*); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx index ad9ca9a4453d..28adc44a21db 100644 --- a/sc/source/ui/namedlg/namemgrtable.cxx +++ b/sc/source/ui/namedlg/namemgrtable.cxx @@ -44,6 +44,7 @@ #define ITEMID_RANGE 2 #define ITEMID_SCOPE 3 +#define MINSIZE 50 String createEntryString(const ScRangeNameLine& rLine) @@ -81,6 +82,8 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::O SetPosSizePixel( Point( 0, aHeadSize.Height() ), Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) ); SetTabs( &nTabs[0], MAP_PIXEL ); + maHeaderBar.SetEndDragHdl( LINK( this, ScRangeManagerTable, HeaderEndDragHdl ) ); + Show(); maHeaderBar.Show(); SetSelectionMode(MULTIPLE_SELECTION); @@ -168,5 +171,66 @@ std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries() return aSelectedEntries; } +namespace { + +void CalculateItemSize(const long& rTableSize, long& rItemNameSize, long& rItemRangeSize) +{ + long aItemScopeSize = rTableSize - rItemNameSize - rItemRangeSize; + + if (rItemNameSize >= MINSIZE && rItemRangeSize >= MINSIZE && aItemScopeSize >= MINSIZE) + return; + + if (rItemNameSize < MINSIZE) + { + long aDiffSize = MINSIZE - rItemNameSize; + if (rItemRangeSize > aItemScopeSize) + rItemRangeSize -= aDiffSize; + else + aItemScopeSize -= aDiffSize; + rItemNameSize = MINSIZE; + } + + if (rItemRangeSize < MINSIZE) + { + long aDiffSize = MINSIZE - rItemRangeSize; + if (rItemNameSize > aItemScopeSize) + rItemNameSize -= aDiffSize; + else + aItemScopeSize -= aDiffSize; + rItemRangeSize = MINSIZE; + } + + if (aItemScopeSize < MINSIZE) + { + long aDiffSize = MINSIZE - aItemScopeSize; + if (rItemNameSize > rItemRangeSize) + rItemNameSize -= aDiffSize; + else + rItemRangeSize -= aDiffSize; + } +} + +} + +IMPL_LINK( ScRangeManagerTable, HeaderEndDragHdl, void*, EMPTYARG) +{ + long aTableSize = maHeaderBar.GetSizePixel().Width(); + long aItemNameSize = maHeaderBar.GetItemSize(ITEMID_NAME); + long aItemRangeSize = maHeaderBar.GetItemSize(ITEMID_RANGE); + + CalculateItemSize(aTableSize, aItemNameSize, aItemRangeSize); + long aItemScopeSize = aTableSize - aItemNameSize - aItemRangeSize; + + Size aSz; + aSz.Width() = aItemNameSize; + SetTab( ITEMID_NAME, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT ); + aSz.Width() += aItemRangeSize; + SetTab( ITEMID_RANGE, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT ); + aSz.Width() += aItemScopeSize; + SetTab( ITEMID_SCOPE, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT ); + + return 0; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |