1*d107581fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*d107581fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*d107581fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*d107581fSAndrew Rist * distributed with this work for additional information 6*d107581fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*d107581fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*d107581fSAndrew Rist * "License"); you may not use this file except in compliance 9*d107581fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*d107581fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*d107581fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*d107581fSAndrew Rist * software distributed under the License is distributed on an 15*d107581fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*d107581fSAndrew Rist * KIND, either express or implied. See the License for the 17*d107581fSAndrew Rist * specific language governing permissions and limitations 18*d107581fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*d107581fSAndrew Rist *************************************************************/ 21*d107581fSAndrew Rist 22*d107581fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_starmath.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <rtl/logfile.hxx> 29cdf0e10cSrcweir #include <svl/eitem.hxx> 30cdf0e10cSrcweir #include <sfx2/app.hxx> 31cdf0e10cSrcweir #include <svl/intitem.hxx> 32cdf0e10cSrcweir #include <svtools/imgdef.hxx> 33cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 34cdf0e10cSrcweir #include <sfx2/imgmgr.hxx> 35cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 36cdf0e10cSrcweir #include "toolbox.hxx" 37cdf0e10cSrcweir #ifndef _STARMATH_HRC 38cdf0e10cSrcweir #include "starmath.hrc" 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir #ifndef _TOOLBOX_HRC_ 41cdf0e10cSrcweir #include "toolbox.hrc" 42cdf0e10cSrcweir #endif 43cdf0e10cSrcweir #include "view.hxx" 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweir //////////////////////////////////////////////////////////// 47cdf0e10cSrcweir 48cdf0e10cSrcweir static sal_uInt16 GetImageListRID( sal_uInt16 nCategoryRID, sal_Bool bHighContrast ) 49cdf0e10cSrcweir { 50cdf0e10cSrcweir sal_uInt16 nRes = 0xFFFF; 51cdf0e10cSrcweir switch (nCategoryRID) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir case RID_UNBINOPS_CAT : nRes = RID_IL_UNBINOPS; break; 54cdf0e10cSrcweir case RID_RELATIONS_CAT : nRes = RID_IL_RELATIONS; break; 55cdf0e10cSrcweir case RID_SETOPERATIONS_CAT : nRes = RID_IL_SETOPERATIONS; break; 56cdf0e10cSrcweir case RID_FUNCTIONS_CAT : nRes = RID_IL_FUNCTIONS; break; 57cdf0e10cSrcweir case RID_OPERATORS_CAT : nRes = RID_IL_OPERATORS; break; 58cdf0e10cSrcweir case RID_ATTRIBUTES_CAT : nRes = RID_IL_ATTRIBUTES; break; 59cdf0e10cSrcweir case RID_BRACKETS_CAT : nRes = RID_IL_BRACKETS; break; 60cdf0e10cSrcweir case RID_FORMAT_CAT : nRes = RID_IL_FORMAT; break; 61cdf0e10cSrcweir case RID_MISC_CAT : nRes = RID_IL_MISC; break; 62cdf0e10cSrcweir default : 63cdf0e10cSrcweir DBG_ERROR( "unkown category" ); 64cdf0e10cSrcweir } 65cdf0e10cSrcweir if (nRes != 0xFFFF && bHighContrast) 66cdf0e10cSrcweir ++nRes; //! the resource ID for the high contrast image list is just +1 compared to the regular ones 67cdf0e10cSrcweir return nRes; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir static sal_Int16 GetToolBoxCategoriesIndex( sal_uInt16 nCategoryRID ) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir sal_Int16 nIdx = -1; 74cdf0e10cSrcweir switch (nCategoryRID) 75cdf0e10cSrcweir { 76cdf0e10cSrcweir case RID_UNBINOPS_CAT : nIdx = 0; break; 77cdf0e10cSrcweir case RID_RELATIONS_CAT : nIdx = 1; break; 78cdf0e10cSrcweir case RID_SETOPERATIONS_CAT : nIdx = 2; break; 79cdf0e10cSrcweir case RID_FUNCTIONS_CAT : nIdx = 3; break; 80cdf0e10cSrcweir case RID_OPERATORS_CAT : nIdx = 4; break; 81cdf0e10cSrcweir case RID_ATTRIBUTES_CAT : nIdx = 5; break; 82cdf0e10cSrcweir case RID_BRACKETS_CAT : nIdx = 6; break; 83cdf0e10cSrcweir case RID_FORMAT_CAT : nIdx = 7; break; 84cdf0e10cSrcweir case RID_MISC_CAT : nIdx = 8; break; 85cdf0e10cSrcweir default: 86cdf0e10cSrcweir ; 87cdf0e10cSrcweir } 88cdf0e10cSrcweir return nIdx; 89cdf0e10cSrcweir } 90cdf0e10cSrcweir 91cdf0e10cSrcweir 92cdf0e10cSrcweir static sal_uInt16 GetCategoryRID( sal_uInt16 nResId ) 93cdf0e10cSrcweir { 94cdf0e10cSrcweir sal_uInt16 nRes = 0xFFFF; 95cdf0e10cSrcweir switch (nResId) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir case RID_IL_UNBINOPS : 98cdf0e10cSrcweir case RID_ILH_UNBINOPS : nRes = RID_UNBINOPS_CAT; break; 99cdf0e10cSrcweir case RID_IL_RELATIONS : 100cdf0e10cSrcweir case RID_ILH_RELATIONS : nRes = RID_RELATIONS_CAT; break; 101cdf0e10cSrcweir case RID_IL_SETOPERATIONS : 102cdf0e10cSrcweir case RID_ILH_SETOPERATIONS : nRes = RID_SETOPERATIONS_CAT; break; 103cdf0e10cSrcweir case RID_IL_FUNCTIONS : 104cdf0e10cSrcweir case RID_ILH_FUNCTIONS : nRes = RID_FUNCTIONS_CAT; break; 105cdf0e10cSrcweir case RID_IL_OPERATORS : 106cdf0e10cSrcweir case RID_ILH_OPERATORS : nRes = RID_OPERATORS_CAT; break; 107cdf0e10cSrcweir case RID_IL_ATTRIBUTES : 108cdf0e10cSrcweir case RID_ILH_ATTRIBUTES : nRes = RID_ATTRIBUTES_CAT; break; 109cdf0e10cSrcweir case RID_IL_BRACKETS : 110cdf0e10cSrcweir case RID_ILH_BRACKETS : nRes = RID_BRACKETS_CAT; break; 111cdf0e10cSrcweir case RID_IL_FORMAT : 112cdf0e10cSrcweir case RID_ILH_FORMAT : nRes = RID_FORMAT_CAT; break; 113cdf0e10cSrcweir case RID_IL_MISC : 114cdf0e10cSrcweir case RID_ILH_MISC : nRes = RID_MISC_CAT; break; 115cdf0e10cSrcweir default : 116cdf0e10cSrcweir if (nResId != RID_IL_CATALOG && nResId != RID_ILH_CATALOG) 117cdf0e10cSrcweir { 118cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 119cdf0e10cSrcweir DBG_ERROR( "unkown category" ); 120cdf0e10cSrcweir #endif 121cdf0e10cSrcweir } 122cdf0e10cSrcweir } 123cdf0e10cSrcweir return nRes; 124cdf0e10cSrcweir } 125cdf0e10cSrcweir 126cdf0e10cSrcweir 127cdf0e10cSrcweir //////////////////////////////////////////////////////////// 128cdf0e10cSrcweir 129cdf0e10cSrcweir 130cdf0e10cSrcweir SmToolBoxWindow::SmToolBoxWindow(SfxBindings *pTmpBindings, 131cdf0e10cSrcweir SfxChildWindow *pChildWindow, 132cdf0e10cSrcweir Window *pParent) : 133cdf0e10cSrcweir SfxFloatingWindow(pTmpBindings, pChildWindow, pParent, SmResId(RID_TOOLBOXWINDOW)), 134cdf0e10cSrcweir aToolBoxCat(this, SmResId(TOOLBOX_CATALOG)), 135cdf0e10cSrcweir aToolBoxCat_Delim(this, SmResId( FL_TOOLBOX_CAT_DELIM )) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir RTL_LOGFILE_CONTEXT( aLog, "starmath: SmToolBoxWindow::SmToolBoxWindow" ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir // allow for cursor travelling between toolbox and sub-categories 140cdf0e10cSrcweir SetStyle( GetStyle() | WB_DIALOGCONTROL ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir nActiveCategoryRID = USHRT_MAX; 143cdf0e10cSrcweir 144cdf0e10cSrcweir aToolBoxCat.SetClickHdl(LINK(this, SmToolBoxWindow, CategoryClickHdl)); 145cdf0e10cSrcweir 146cdf0e10cSrcweir sal_uInt16 i; 147cdf0e10cSrcweir for (i = 0; i < NUM_TBX_CATEGORIES; ++i) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir ToolBox *pBox = new ToolBox(this, SmResId( TOOLBOX_CAT_A + i )); 150cdf0e10cSrcweir vToolBoxCategories[i] = pBox; 151cdf0e10cSrcweir pBox->SetSelectHdl(LINK(this, SmToolBoxWindow, CmdSelectHdl)); 152cdf0e10cSrcweir } 153cdf0e10cSrcweir pToolBoxCmd = vToolBoxCategories[0]; 154cdf0e10cSrcweir 155cdf0e10cSrcweir for (i = 0; i <= NUM_TBX_CATEGORIES; ++i) 156cdf0e10cSrcweir { 157cdf0e10cSrcweir aImageLists [i] = 0; 158cdf0e10cSrcweir aImageListsH[i] = 0; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir FreeResource(); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir 164cdf0e10cSrcweir SmToolBoxWindow::~SmToolBoxWindow() 165cdf0e10cSrcweir { 166cdf0e10cSrcweir int i; 167cdf0e10cSrcweir for (i = 0; i < NUM_TBX_CATEGORIES; ++i) 168cdf0e10cSrcweir { 169cdf0e10cSrcweir ToolBox *pBox = vToolBoxCategories[i]; 170cdf0e10cSrcweir delete pBox; 171cdf0e10cSrcweir } 172cdf0e10cSrcweir for (i = 0; i < NUM_TBX_CATEGORIES + 1; ++i) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir delete aImageLists[i]; 175cdf0e10cSrcweir delete aImageListsH[i]; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir } 178cdf0e10cSrcweir 179cdf0e10cSrcweir 180cdf0e10cSrcweir SmViewShell * SmToolBoxWindow::GetView() 181cdf0e10cSrcweir { 182cdf0e10cSrcweir SfxViewShell *pView = GetBindings().GetDispatcher()->GetFrame()->GetViewShell(); 183cdf0e10cSrcweir return PTR_CAST(SmViewShell, pView); 184cdf0e10cSrcweir } 185cdf0e10cSrcweir 186cdf0e10cSrcweir 187cdf0e10cSrcweir const ImageList * SmToolBoxWindow::GetImageList( sal_uInt16 nResId, sal_Bool bHighContrast ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir // creates the image list via its resource id and stores that 190cdf0e10cSrcweir // list for later use in the respective array. 191cdf0e10cSrcweir 192cdf0e10cSrcweir const ImageList *pIL = 0; 193cdf0e10cSrcweir 194cdf0e10cSrcweir // get index to use 195cdf0e10cSrcweir sal_uInt16 nCategoryRID = GetCategoryRID( nResId ); 196cdf0e10cSrcweir sal_Int16 nIndex = GetToolBoxCategoriesIndex( nCategoryRID ); 197cdf0e10cSrcweir if (nIndex == -1 && (nResId == RID_IL_CATALOG || nResId == RID_ILH_CATALOG)) 198cdf0e10cSrcweir nIndex = NUM_TBX_CATEGORIES; 199cdf0e10cSrcweir 200cdf0e10cSrcweir if (nIndex >= 0) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir ImageList **pImgList = bHighContrast ? aImageListsH : aImageLists; 203cdf0e10cSrcweir if (!pImgList[ nIndex ]) 204cdf0e10cSrcweir pImgList[ nIndex ] = new ImageList( SmResId(nResId) ); 205cdf0e10cSrcweir pIL = pImgList[ nIndex ]; 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir DBG_ASSERT( pIL, "image list not found!" ); 209cdf0e10cSrcweir return pIL; 210cdf0e10cSrcweir } 211cdf0e10cSrcweir 212cdf0e10cSrcweir 213cdf0e10cSrcweir void SmToolBoxWindow::ApplyImageLists( sal_uInt16 nCategoryRID ) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir sal_Bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 216cdf0e10cSrcweir 217cdf0e10cSrcweir // set image list for toolbox 'catalog' 218cdf0e10cSrcweir const ImageList *pImageList = GetImageList( bHighContrast ? RID_ILH_CATALOG : RID_IL_CATALOG, bHighContrast ); 219cdf0e10cSrcweir DBG_ASSERT( pImageList, "image list missing" ); 220cdf0e10cSrcweir if (pImageList) 221cdf0e10cSrcweir aToolBoxCat.SetImageList( *pImageList ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir // set image list for active (visible) category of 'catalog' 224cdf0e10cSrcweir sal_Int16 nIdx = GetToolBoxCategoriesIndex( nCategoryRID ); 225cdf0e10cSrcweir sal_uInt16 nResId = GetImageListRID( nCategoryRID, bHighContrast ); 226cdf0e10cSrcweir pImageList = GetImageList( nResId, bHighContrast ); 227cdf0e10cSrcweir DBG_ASSERT( pImageList && nIdx >= 0, "image list or index missing" ); 228cdf0e10cSrcweir if (pImageList && nIdx >= 0) 229cdf0e10cSrcweir vToolBoxCategories[ nIdx ]->SetImageList( *pImageList ); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir void SmToolBoxWindow::DataChanged( const DataChangedEvent &rEvt ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir if ( (rEvt.GetType() == DATACHANGED_SETTINGS) && (rEvt.GetFlags() & SETTINGS_STYLE) ) 235cdf0e10cSrcweir ApplyImageLists( nActiveCategoryRID ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir SfxFloatingWindow::DataChanged( rEvt ); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir void SmToolBoxWindow::StateChanged( StateChangedType nStateChange ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir static sal_Bool bSetPosition = sal_True; 243cdf0e10cSrcweir if (STATE_CHANGE_INITSHOW == nStateChange) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir SetCategory( nActiveCategoryRID == USHRT_MAX ? RID_UNBINOPS_CAT : nActiveCategoryRID ); 246cdf0e10cSrcweir 247cdf0e10cSrcweir // calculate initial position to be used after creation of the window... 248cdf0e10cSrcweir AdjustPosSize( bSetPosition ); 249cdf0e10cSrcweir bSetPosition = sal_False; 250cdf0e10cSrcweir } 251cdf0e10cSrcweir //... otherwise the base class will remember the last position of the window 252cdf0e10cSrcweir SfxFloatingWindow::StateChanged( nStateChange ); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir 256cdf0e10cSrcweir void SmToolBoxWindow::AdjustPosSize( sal_Bool bSetPos ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir Size aCatSize( aToolBoxCat.CalcWindowSizePixel( 2 ) ); 259cdf0e10cSrcweir Size aCmdSize( pToolBoxCmd->CalcWindowSizePixel( 4 /* see nLines in SetCategory*/ ) ); 260cdf0e10cSrcweir DBG_ASSERT( aCatSize.Width() == aCmdSize.Width(), "width mismatch" ); 261cdf0e10cSrcweir 262cdf0e10cSrcweir // catalog settings 263cdf0e10cSrcweir aToolBoxCat.SetPosPixel( Point(0, 3) ); 264cdf0e10cSrcweir aToolBoxCat.SetSizePixel( aCatSize ); 265cdf0e10cSrcweir // settings for catalog / category delimiter 266cdf0e10cSrcweir Point aP( aToolBoxCat_Delim.GetPosPixel() ); 267cdf0e10cSrcweir aP.X() = 0; 268cdf0e10cSrcweir aToolBoxCat_Delim.SetPosPixel( aP ); 269cdf0e10cSrcweir aToolBoxCat_Delim.SetSizePixel( Size( aCatSize.Width(), aToolBoxCat_Delim.GetSizePixel().Height() ) ); 270cdf0e10cSrcweir // category settings 271cdf0e10cSrcweir aP.Y() += aToolBoxCat_Delim.GetSizePixel().Height(); 272cdf0e10cSrcweir for (int i = 0; i < NUM_TBX_CATEGORIES; ++i) 273cdf0e10cSrcweir { 274cdf0e10cSrcweir vToolBoxCategories[i]->SetPosPixel( aP ); 275cdf0e10cSrcweir vToolBoxCategories[i]->SetSizePixel( aCmdSize ); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir // main window settings 278cdf0e10cSrcweir Size aWndSize ( aCatSize.Width(), pToolBoxCmd->GetPosPixel().Y() + pToolBoxCmd->GetSizePixel().Height() + 3); 279cdf0e10cSrcweir SetOutputSizePixel( aWndSize ); 280cdf0e10cSrcweir 281cdf0e10cSrcweir if (bSetPos) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir SmViewShell *pView = GetView(); 284cdf0e10cSrcweir DBG_ASSERT( pView, "view shell missing" ); 285cdf0e10cSrcweir Point aPos( 50, 75 ); 286cdf0e10cSrcweir if (pView) 287cdf0e10cSrcweir { 288cdf0e10cSrcweir SmGraphicWindow &rWin = pView->GetGraphicWindow(); 289cdf0e10cSrcweir aPos = Point( rWin.OutputToScreenPixel( 290cdf0e10cSrcweir Point( rWin.GetSizePixel().Width() - aWndSize.Width(), 0) ) ); 291cdf0e10cSrcweir } 292cdf0e10cSrcweir if (aPos.X() < 0) 293cdf0e10cSrcweir aPos.X() = 0; 294cdf0e10cSrcweir if (aPos.Y() < 0) 295cdf0e10cSrcweir aPos.Y() = 0; 296cdf0e10cSrcweir SetPosPixel( aPos ); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir 301cdf0e10cSrcweir sal_Bool SmToolBoxWindow::Close() 302cdf0e10cSrcweir { 303cdf0e10cSrcweir SmViewShell *pViewSh = GetView(); 304cdf0e10cSrcweir if (pViewSh) 305cdf0e10cSrcweir pViewSh->GetViewFrame()->GetDispatcher()->Execute( 306cdf0e10cSrcweir SID_TOOLBOX, SFX_CALLMODE_STANDARD, 307cdf0e10cSrcweir new SfxBoolItem(SID_TOOLBOX, sal_False), 0L); 308cdf0e10cSrcweir return sal_True; 309cdf0e10cSrcweir } 310cdf0e10cSrcweir 311cdf0e10cSrcweir void SmToolBoxWindow::GetFocus() 312cdf0e10cSrcweir { 313cdf0e10cSrcweir // give focus to category toolbox 314cdf0e10cSrcweir // (allow for cursor travelling when a category is selected with the mouse) 315cdf0e10cSrcweir aToolBoxCat.GrabFocus(); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir 318cdf0e10cSrcweir void SmToolBoxWindow::SetCategory(sal_uInt16 nCategoryRID) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir if (nCategoryRID != nActiveCategoryRID) 321cdf0e10cSrcweir ApplyImageLists( nCategoryRID ); 322cdf0e10cSrcweir 323cdf0e10cSrcweir sal_uInt16 nLines; 324cdf0e10cSrcweir // check for valid resource id 325cdf0e10cSrcweir switch (nCategoryRID) 326cdf0e10cSrcweir { 327cdf0e10cSrcweir case RID_UNBINOPS_CAT : nLines = 4; break; 328cdf0e10cSrcweir case RID_RELATIONS_CAT: nLines = 4; break; 329cdf0e10cSrcweir case RID_SETOPERATIONS_CAT: nLines = 4; break; 330cdf0e10cSrcweir case RID_FUNCTIONS_CAT: nLines = 4; break; 331cdf0e10cSrcweir case RID_OPERATORS_CAT: nLines = 3; break; 332cdf0e10cSrcweir case RID_ATTRIBUTES_CAT: nLines = 4; break; 333cdf0e10cSrcweir case RID_MISC_CAT: nLines = 4; break; 334cdf0e10cSrcweir case RID_BRACKETS_CAT: nLines = 4; break; 335cdf0e10cSrcweir case RID_FORMAT_CAT: nLines = 3; break; 336cdf0e10cSrcweir default: 337cdf0e10cSrcweir // nothing to be done 338cdf0e10cSrcweir return; 339cdf0e10cSrcweir } 340cdf0e10cSrcweir 341cdf0e10cSrcweir pToolBoxCmd->Hide(); 342cdf0e10cSrcweir 343cdf0e10cSrcweir sal_Int16 nIdx = GetToolBoxCategoriesIndex( nCategoryRID ); 344cdf0e10cSrcweir DBG_ASSERT( nIdx >= 0, "unkown category" ); 345cdf0e10cSrcweir if (nIdx >= 0) 346cdf0e10cSrcweir pToolBoxCmd = vToolBoxCategories[nIdx]; 347cdf0e10cSrcweir 348cdf0e10cSrcweir // calculate actual size of window to use 349cdf0e10cSrcweir Size aCatSize( aToolBoxCat.CalcWindowSizePixel( 2 ) ); 350cdf0e10cSrcweir Size aCmdSize( pToolBoxCmd->CalcWindowSizePixel( nLines ) ); 351cdf0e10cSrcweir DBG_ASSERT( aCatSize.Width() == aCmdSize.Width(), "width mismatch" ); 352cdf0e10cSrcweir // main window settings 353cdf0e10cSrcweir Size aWndSize ( aCatSize.Width(), pToolBoxCmd->GetPosPixel().Y() + aCmdSize.Height() + 3); 354cdf0e10cSrcweir SetOutputSizePixel( aWndSize ); 355cdf0e10cSrcweir 356cdf0e10cSrcweir if (nActiveCategoryRID) 357cdf0e10cSrcweir aToolBoxCat.CheckItem(nActiveCategoryRID, sal_False); 358cdf0e10cSrcweir nActiveCategoryRID = nCategoryRID; 359cdf0e10cSrcweir aToolBoxCat.CheckItem(nActiveCategoryRID, sal_True); 360cdf0e10cSrcweir 361cdf0e10cSrcweir pToolBoxCmd->Show(); 362cdf0e10cSrcweir } 363cdf0e10cSrcweir 364cdf0e10cSrcweir 365cdf0e10cSrcweir IMPL_LINK( SmToolBoxWindow, CategoryClickHdl, ToolBox*, pToolBox) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir int nItemId = pToolBox->GetCurItemId(); 368cdf0e10cSrcweir if (nItemId != 0) 369cdf0e10cSrcweir SetCategory( sal::static_int_cast< sal_uInt16 >(nItemId) ); 370cdf0e10cSrcweir return 0; 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir 374cdf0e10cSrcweir IMPL_LINK( SmToolBoxWindow, CmdSelectHdl, ToolBox*, pToolBox) 375cdf0e10cSrcweir { 376cdf0e10cSrcweir SmViewShell *pViewSh = GetView(); 377cdf0e10cSrcweir if (pViewSh) 378cdf0e10cSrcweir pViewSh->GetViewFrame()->GetDispatcher()->Execute( 379cdf0e10cSrcweir SID_INSERTCOMMAND, SFX_CALLMODE_STANDARD, 380cdf0e10cSrcweir new SfxInt16Item(SID_INSERTCOMMAND, pToolBox->GetCurItemId()), 0L); 381cdf0e10cSrcweir return 0; 382cdf0e10cSrcweir } 383cdf0e10cSrcweir 384cdf0e10cSrcweir 385cdf0e10cSrcweir /**************************************************************************/ 386cdf0e10cSrcweir 387cdf0e10cSrcweir SFX_IMPL_FLOATINGWINDOW(SmToolBoxWrapper, SID_TOOLBOXWINDOW); 388cdf0e10cSrcweir 389cdf0e10cSrcweir SmToolBoxWrapper::SmToolBoxWrapper(Window *pParentWindow, 390cdf0e10cSrcweir sal_uInt16 nId, SfxBindings* pBindings, 391cdf0e10cSrcweir SfxChildWinInfo *pInfo) : 392cdf0e10cSrcweir SfxChildWindow(pParentWindow, nId) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_NOALIGNMENT; 395cdf0e10cSrcweir 396cdf0e10cSrcweir pWindow = new SmToolBoxWindow(pBindings, this, pParentWindow); 397cdf0e10cSrcweir ((SfxFloatingWindow *)pWindow)->Initialize(pInfo); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir 400cdf0e10cSrcweir 401