1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_svtools.hxx" 30 #include <vcl/svapp.hxx> 31 #include <vcl/sound.hxx> 32 #include <vcl/msgbox.hxx> 33 #include <vcl/floatwin.hxx> 34 #include <vcl/menu.hxx> 35 #include <vcl/wrkwin.hxx> 36 #include <vcl/edit.hxx> 37 #include <svtools/brwbox.hxx> 38 #include <vcl/group.hxx> 39 40 #ifndef _SV_BUTTON_HXX //autogen 41 #include <vcl/button.hxx> 42 #endif 43 #include <vcl/dialog.hxx> 44 45 #define MID_BROWSER 10 46 #define MID_MODE 11 47 #define MID_EVENTVIEW 12 48 #define MID_INVALIDATE 13 49 #define MID_CLEAR 14 50 #define MID_ROW 20 51 #define MID_INSERTROW_BEFORE 21 52 #define MID_INSERTROW_AT 22 53 #define MID_INSERTROW_BEHIND 23 54 #define MID_REMOVEROW_BEFORE 24 55 #define MID_REMOVEROW_AT 25 56 #define MID_REMOVEROW_BEHIND 26 57 #define MID_MODIFYROW_BEFORE 27 58 #define MID_MODIFYROW_AT 28 59 #define MID_MODIFYROW_BEHIND 29 60 #define MID_COL 30 61 #define MID_INSERTCOL 31 62 #define MID_REMOVECOL 32 63 #define MID_MOVECOLLEFT 33 64 #define MID_MOVECOLRIGHT 34 65 #define MID_SELECTIONS 60 66 #define MID_SELECTROW 61 67 #define MID_SELECTALL 62 68 #define MID_SELECTNONE 63 69 #define MID_INVERSE 64 70 #define MID_EXTRAS 70 71 #define MID_STARMONEY_1 71 72 73 //================================================================== 74 75 class BrowseModeDialog: public ModalDialog 76 { 77 RadioButton aSingleSel; 78 RadioButton aMultiSel; 79 GroupBox aSelGroup; 80 81 CheckBox aKeepHighlight; 82 CheckBox aColumnCursor; 83 CheckBox aThumbDragging; 84 GroupBox aOptGroup; 85 86 RadioButton aNoHLines; 87 RadioButton aDottedHLines; 88 RadioButton aFullHLines; 89 GroupBox aHLinGroup; 90 91 RadioButton aNoVLines; 92 RadioButton aDottedVLines; 93 RadioButton aFullVLines; 94 GroupBox aVLinGroup; 95 96 OKButton aOKButton; 97 CancelButton aCancelButton; 98 99 public: 100 BrowseModeDialog( Window *pParent ); 101 102 void SetMode( BrowserMode eMode ); 103 BrowserMode GetMode() const; 104 }; 105 106 //================================================================== 107 108 DECLARE_LIST(DataList,long); 109 110 class Browser: public BrowseBox 111 { 112 friend class AppWindow; 113 114 DataList aRows; 115 sal_Bool bInverse; 116 Edit* pEdit; 117 118 protected: 119 virtual long GetRowCount() const; 120 virtual sal_Bool SeekRow( long nRow ); 121 virtual void PaintField( OutputDevice& rDev, const Rectangle& rRect, 122 sal_uInt16 nColumnId ) const; 123 124 virtual void Select(); 125 virtual void DoubleClick(); 126 virtual void CursorMoved(); 127 virtual void StartScroll(); 128 virtual void EndScroll(); 129 virtual void Command( const CommandEvent &eEvt ); 130 131 virtual sal_Bool StartDragging( Pointer& rMovePtr, 132 Pointer& rCopyPtr ); 133 virtual void EndDragging( const DropAction &rAction ); 134 virtual void MouseButtonDown( const BrowserMouseEvent &rEvt ); 135 136 public: 137 Browser( AppWindow* pParent, BrowserMode eMode ); 138 ~Browser(); 139 140 void SetInverseSelection( sal_Bool bInverseSel ) 141 { bInverse = bInverseSel; } 142 }; 143 144 //------------------------------------------------------------------ 145 146 class AppWindow: public WorkWindow 147 { 148 MenuBar aMenu; 149 PopupMenu aBrwMenu, aRowMenu, aColMenu, aSelMenu, aExtMenu; 150 Edit aEdit; 151 Browser aBrowser; 152 BrowserMode eCurMode; 153 FloatingWindow *pEventView; 154 sal_uLong nNewRowNo; 155 156 private: 157 DECL_LINK( Modify, void * ); 158 DECL_LINK( MenuSelect, Menu * ); 159 160 protected: 161 void Resize(); 162 void Activate(); 163 164 public: 165 AppWindow(); 166 ~AppWindow(); 167 168 void Event( const String &rEvent ); 169 }; 170 171 //------------------------------------------------------------------ 172 173 class App: public Application 174 { 175 protected: 176 void Main(); 177 178 public: 179 App(); 180 ~App(); 181 }; 182 183 //================================================================== 184 185 App aApp; 186 187 //================================================================== 188 189 BrowseModeDialog::BrowseModeDialog( Window *pParent ): 190 ModalDialog( pParent, WinBits( WB_MOVEABLE | WB_CLOSEABLE | WB_3DLOOK ) ), 191 192 aSingleSel( this ), 193 aMultiSel( this ), 194 aSelGroup( this ), 195 196 aKeepHighlight( this ), 197 aColumnCursor( this ), 198 aThumbDragging( this ), 199 aOptGroup( this ), 200 201 aNoHLines( this ), 202 aDottedHLines( this ), 203 aFullHLines( this ), 204 aHLinGroup( this ), 205 206 aNoVLines( this, WinBits( WB_GROUP ) ), 207 aDottedVLines( this ), 208 aFullVLines( this ), 209 aVLinGroup( this ), 210 211 aOKButton( this ), 212 aCancelButton( this ) 213 { 214 SetOutputSizePixel( Size( 290, 220 ) ); 215 SetText( String( "Browse Mode", RTL_TEXTENCODING_IBM_850 ) ); 216 217 aSingleSel.SetText( String( "single", RTL_TEXTENCODING_IBM_850 ) ); 218 aMultiSel.SetText( String( "multi", RTL_TEXTENCODING_IBM_850 ) ); 219 aSelGroup.SetText( String( " Selection ", RTL_TEXTENCODING_IBM_850 ) ); 220 221 aKeepHighlight.SetText( String( "keep highlight", RTL_TEXTENCODING_IBM_850 ) ); 222 aColumnCursor.SetText( String( "column cursor", RTL_TEXTENCODING_IBM_850 ) ); 223 aThumbDragging.SetText( String( "thumb dragging", RTL_TEXTENCODING_IBM_850 ) ); 224 aOptGroup.SetText( String( " Options ", RTL_TEXTENCODING_IBM_850 ) ); 225 226 aNoHLines.SetText( String( "none", RTL_TEXTENCODING_IBM_850 ) ); 227 aDottedHLines.SetText( String( "dotted", RTL_TEXTENCODING_IBM_850 ) ); 228 aFullHLines.SetText( String( "full", RTL_TEXTENCODING_IBM_850 ) ); 229 aHLinGroup.SetText( String( " Horizontal ", RTL_TEXTENCODING_IBM_850 ) ); 230 231 aNoVLines.SetText( String( "none", RTL_TEXTENCODING_IBM_850 ) ); 232 aDottedVLines.SetText( String( "dotted", RTL_TEXTENCODING_IBM_850 ) ); 233 aFullVLines.SetText( String( "full", RTL_TEXTENCODING_IBM_850 ) ); 234 aVLinGroup.SetText( String( " Vertical ", RTL_TEXTENCODING_IBM_850 ) ); 235 236 aSingleSel.SetPosSizePixel( Point( 20, 30 ), Size( 80, 14 ) ); 237 aMultiSel.SetPosSizePixel( Point( 20, 70 ), Size( 80, 14 ) ); 238 aSelGroup.SetPosSizePixel( Point( 10, 10 ), Size( 100, 80 ) ); 239 aSelGroup.SetText( String( " Selection ", RTL_TEXTENCODING_IBM_850 ) ); 240 241 aKeepHighlight.SetPosSizePixel( Point( 130, 30 ), Size( 140, 14 ) ); 242 aColumnCursor.SetPosSizePixel( Point( 130, 50 ), Size( 140, 14 ) ); 243 aThumbDragging.SetPosSizePixel( Point( 130, 70 ), Size( 140, 14 ) ); 244 aOptGroup.SetPosSizePixel( Point( 120, 10 ), Size( 160, 80 ) ); 245 aOptGroup.SetText( String( " Options ", RTL_TEXTENCODING_IBM_850 ) ); 246 247 aNoHLines.SetPosSizePixel( Point( 20, 120 ), Size( 80, 14 ) ); 248 aDottedHLines.SetPosSizePixel( Point( 20, 140 ), Size( 80, 14 ) ); 249 aFullHLines.SetPosSizePixel( Point( 20, 160 ), Size( 80, 14 ) ); 250 aHLinGroup.SetPosSizePixel( Point( 10, 100 ), Size( 100, 80 ) ); 251 aHLinGroup.SetText( String( " horizontal ", RTL_TEXTENCODING_IBM_850 ) ); 252 253 aNoVLines.SetPosSizePixel( Point( 130, 120 ), Size( 80, 14 ) ); 254 aDottedVLines.SetPosSizePixel( Point( 130, 140 ), Size( 80, 14 ) ); 255 aFullVLines.SetPosSizePixel( Point( 130, 160 ), Size( 80, 14 ) ); 256 aVLinGroup.SetPosSizePixel( Point( 120, 100 ), Size( 100, 80 ) ); 257 aVLinGroup.SetText( String( " vertical ", RTL_TEXTENCODING_IBM_850 ) ); 258 259 aOKButton.SetPosSizePixel( Point( 10, 190 ), Size( 100, 22 ) ); 260 aCancelButton.SetPosSizePixel( Point( 120, 190 ), Size( 100, 22 ) ); 261 262 aSingleSel.Check(); 263 aNoHLines.Check(); 264 aNoVLines.Check(); 265 266 aSingleSel.Show(); 267 aMultiSel.Show(); 268 aSelGroup.Show(); 269 270 aKeepHighlight.Show(); 271 aColumnCursor.Show(); 272 aThumbDragging.Show(); 273 aOptGroup.Show(); 274 275 aNoHLines.Show(); 276 aDottedHLines.Show(); 277 aFullHLines.Show(); 278 aHLinGroup.Show(); 279 280 aNoVLines.Show(); 281 aDottedVLines.Show(); 282 aFullVLines.Show(); 283 aVLinGroup.Show(); 284 285 aOKButton.Show(); 286 aCancelButton.Show(); 287 } 288 289 //------------------------------------------------------------------ 290 291 void BrowseModeDialog::SetMode( BrowserMode eMode ) 292 { 293 if ( ( eMode & BROWSER_COLUMNSELECTION ) == BROWSER_COLUMNSELECTION ) 294 aColumnCursor.Check(); 295 if ( ( eMode & BROWSER_MULTISELECTION ) == BROWSER_MULTISELECTION ) 296 aMultiSel.Check(); 297 if ( ( eMode & BROWSER_THUMBDRAGGING ) == BROWSER_THUMBDRAGGING ) 298 aThumbDragging.Check(); 299 if ( ( eMode & BROWSER_KEEPHIGHLIGHT ) == BROWSER_KEEPHIGHLIGHT ) 300 aKeepHighlight.Check(); 301 if ( ( eMode & BROWSER_HLINESFULL ) == BROWSER_HLINESFULL ) 302 aFullHLines.Check(); 303 if ( ( eMode & BROWSER_VLINESFULL ) == BROWSER_VLINESFULL ) 304 aFullVLines.Check(); 305 if ( ( eMode & BROWSER_HLINESDOTS ) == BROWSER_HLINESDOTS ) 306 aDottedHLines.Check(); 307 if ( ( eMode & BROWSER_VLINESDOTS ) == BROWSER_VLINESDOTS ) 308 aDottedVLines.Check(); 309 } 310 311 //------------------------------------------------------------------ 312 313 BrowserMode BrowseModeDialog::GetMode() const 314 { 315 BrowserMode eMode = 0; 316 317 if ( aColumnCursor.IsChecked() ) 318 eMode |= BROWSER_COLUMNSELECTION; 319 if ( aMultiSel.IsChecked() ) 320 eMode |= BROWSER_MULTISELECTION; 321 322 if ( aKeepHighlight.IsChecked() ) 323 eMode |= BROWSER_KEEPHIGHLIGHT; 324 if ( aThumbDragging.IsChecked() ) 325 eMode |= BROWSER_THUMBDRAGGING; 326 327 if ( aDottedHLines.IsChecked() ) 328 eMode |= BROWSER_HLINESDOTS; 329 if ( aFullHLines.IsChecked() ) 330 eMode |= BROWSER_HLINESFULL; 331 332 if ( aDottedVLines.IsChecked() ) 333 eMode |= BROWSER_VLINESDOTS; 334 if ( aFullVLines.IsChecked() ) 335 eMode |= BROWSER_VLINESFULL; 336 337 return eMode; 338 } 339 340 //================================================================== 341 342 Browser::Browser( AppWindow* pParent, BrowserMode eMode ): 343 BrowseBox( pParent, WinBits(WB_DRAG), eMode ), 344 bInverse(sal_False), 345 pEdit( 0 ) 346 { 347 for ( long n = 0; n < 100; ++n ) 348 aRows.Insert( n, LIST_APPEND ); 349 350 //InsertHandleColumn( 30 ); 351 InsertDataColumn( 1, String( "eins", RTL_TEXTENCODING_IBM_850 ), 85 ); // FreezeColumn( 1 ); 352 InsertDataColumn( 2, String( "zwei", RTL_TEXTENCODING_IBM_850 ), 85 ); // FreezeColumn( 2 ); 353 InsertDataColumn( 3, String( "drei", RTL_TEXTENCODING_IBM_850 ), 85 ); 354 InsertDataColumn( 4, String( "vier", RTL_TEXTENCODING_IBM_850 ), 85 ); 355 InsertDataColumn( 5, String( "fuenf", RTL_TEXTENCODING_IBM_850 ), 85 ); 356 InsertDataColumn( 6, String( "sechs", RTL_TEXTENCODING_IBM_850 ), 85 ); 357 InsertDataColumn( 7, String( "sieben", RTL_TEXTENCODING_IBM_850 ), 85 ); 358 InsertDataColumn( 8, String( "acht", RTL_TEXTENCODING_IBM_850 ), 85 ); 359 InsertDataColumn( 9, String( "neun", RTL_TEXTENCODING_IBM_850 ), 85 ); 360 InsertDataColumn(10, String( "zehn", RTL_TEXTENCODING_IBM_850 ), 85 ); 361 } 362 363 //------------------------------------------------------------------ 364 365 Browser::~Browser() 366 { 367 delete pEdit; 368 } 369 370 //------------------------------------------------------------------ 371 372 sal_Bool Browser::StartDragging( Pointer& rMovePtr, Pointer& rCopyPtr ) 373 { 374 rMovePtr = Pointer( POINTER_MOVEDATA ); 375 rCopyPtr = Pointer( POINTER_COPYDATA ); 376 return sal_True; 377 } 378 379 //------------------------------------------------------------------ 380 381 void Browser::MouseButtonDown( const BrowserMouseEvent &rEvt ) 382 { 383 if ( 3 == rEvt.GetClicks() ) 384 InfoBox( 0, String( GetColumnAtXPosPixel(rEvt.GetPosPixel().X() ) ) ).Execute(); 385 else 386 BrowseBox::MouseButtonDown( rEvt ); 387 } 388 389 //------------------------------------------------------------------ 390 391 void Browser::EndDragging( const DropAction &rAction ) 392 { 393 } 394 395 //------------------------------------------------------------------ 396 397 void Browser::StartScroll() 398 { 399 ( (AppWindow*) GetParent() )->Event( String( "StartScroll", RTL_TEXTENCODING_IBM_850 ) ); 400 if ( pEdit ) 401 pEdit->Hide(); 402 BrowseBox::StartScroll(); 403 } 404 405 //------------------------------------------------------------------ 406 407 void Browser::EndScroll() 408 { 409 BrowseBox::EndScroll(); 410 ( (AppWindow*) GetParent() )->Event( String( "EndScroll", RTL_TEXTENCODING_IBM_850 ) ); 411 if ( pEdit ) 412 pEdit->Show(); 413 } 414 //------------------------------------------------------------------ 415 416 void Browser::Command( const CommandEvent &rEvt ) 417 { 418 String aEvent( String( "Command at ", RTL_TEXTENCODING_IBM_850 ) ); 419 aEvent += rEvt.GetMousePosPixel().X(); 420 aEvent += String( ":", RTL_TEXTENCODING_IBM_850 ); 421 aEvent += rEvt.GetMousePosPixel().Y(); 422 ( (AppWindow*) GetParent() )->Event( aEvent ); 423 BrowseBox::Command(rEvt); 424 } 425 426 //------------------------------------------------------------------ 427 428 void Browser::Select() 429 { 430 String aEvent( String( "Select: ", RTL_TEXTENCODING_IBM_850 ) ); 431 DELETEZ(pEdit); 432 for ( long nRow = FirstSelectedRow(bInverse); nRow >= 0; nRow = NextSelectedRow() ) 433 { 434 if ( bInverse ) 435 aEvent += String( String( "~", RTL_TEXTENCODING_IBM_850 ) ); 436 aEvent += String( nRow ); 437 aEvent += String( ", ", RTL_TEXTENCODING_IBM_850 ); 438 } 439 aEvent.Erase( aEvent.Len() - 2 ); 440 441 ( (AppWindow*) GetParent() )->Event( aEvent ); 442 } 443 444 //------------------------------------------------------------------ 445 446 void Browser::DoubleClick() 447 { 448 String aEvent( String( "DoubleClick: ", RTL_TEXTENCODING_IBM_850 ) ); 449 aEvent += String( GetCurRow() ); 450 aEvent += String( String( ", ", RTL_TEXTENCODING_IBM_850 ) ); 451 aEvent += String( FirstSelectedRow() ); 452 ( (AppWindow*) GetParent() )->Event( aEvent ); 453 454 SetNoSelection(); 455 if ( !pEdit ) 456 pEdit = new Edit( &GetDataWindow() ); 457 Rectangle aRect( GetFieldRect( GetCurColumnId() ) ); 458 pEdit->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() ); 459 pEdit->Show(); 460 pEdit->GrabFocus(); 461 } 462 463 //------------------------------------------------------------------ 464 465 void Browser::CursorMoved() 466 { 467 String aEvent( String( "Cursor: ", RTL_TEXTENCODING_IBM_850 ) ); 468 aEvent += String( GetCurRow() ); 469 aEvent += String( ":", RTL_TEXTENCODING_IBM_850 ); 470 aEvent += String( GetCurColumnId() ); 471 ( (AppWindow*) GetParent() )->Event( aEvent ); 472 if ( IsFieldVisible( GetCurRow(), GetCurColumnId(), sal_True ) ) 473 ( (AppWindow*) GetParent() )->Event( String( "completely visible", RTL_TEXTENCODING_IBM_850 ) ); 474 else if ( IsFieldVisible( 1, GetCurColumnId(), sal_False) ) 475 ( (AppWindow*) GetParent() )->Event( String( "partly visible", RTL_TEXTENCODING_IBM_850 ) ); 476 else 477 ( (AppWindow*) GetParent() )->Event( String( "not visible", RTL_TEXTENCODING_IBM_850 ) ); 478 479 DELETEZ(pEdit); 480 } 481 482 //------------------------------------------------------------------ 483 484 long Browser::GetRowCount() const 485 { 486 return aRows.Count(); 487 } 488 489 //------------------------------------------------------------------ 490 491 sal_Bool Browser::SeekRow( long nRow ) 492 { 493 if ( nRow >= 0 && nRow < (long) aRows.Count() ) 494 { 495 aRows.Seek(nRow); 496 return sal_True; 497 } 498 return sal_False; 499 } 500 501 //------------------------------------------------------------------ 502 503 void Browser::PaintField( OutputDevice& rDev, const Rectangle& rRect, 504 sal_uInt16 nColumnId ) const 505 { 506 rDev.SetClipRegion( rRect ); 507 String aText( aRows.GetCurObject() ); 508 aText += String( ".", RTL_TEXTENCODING_IBM_850 ); 509 aText += String( nColumnId ); 510 rDev.DrawText( rRect.TopLeft(), aText ); 511 } 512 513 //================================================================== 514 515 AppWindow::AppWindow(): 516 WorkWindow( 0, WinBits(WB_APP|WB_STDWORK) ), 517 aEdit( this, WinBits( WB_BORDER ) ), 518 aBrowser( this, 0 ), 519 eCurMode( 0 ), 520 pEventView( 0 ), 521 nNewRowNo( 2000L ) 522 { 523 SetText( String( "BrowseBox Testframe", RTL_TEXTENCODING_IBM_850 ) ); 524 525 aMenu.InsertItem( MID_BROWSER, String( "~Browser", RTL_TEXTENCODING_IBM_850 ) ); 526 aMenu.SetPopupMenu( MID_BROWSER, &aBrwMenu ); 527 aBrwMenu.InsertItem( MID_MODE, String( "~Mode...", RTL_TEXTENCODING_IBM_850 ) ); 528 aBrwMenu.InsertItem( MID_EVENTVIEW, String( "~Event-Viewer", RTL_TEXTENCODING_IBM_850 ) ); 529 aBrwMenu.InsertSeparator(); 530 aBrwMenu.InsertItem( MID_INVALIDATE, String( "~Invalidate", RTL_TEXTENCODING_IBM_850 ) ); 531 aBrwMenu.InsertItem( MID_CLEAR, String( "~Clear", RTL_TEXTENCODING_IBM_850 ) ); 532 aMenu.InsertItem( MID_ROW, String( "~Row", RTL_TEXTENCODING_IBM_850 ) ); 533 aMenu.SetPopupMenu( MID_ROW, &aRowMenu ); 534 aRowMenu.InsertItem( MID_INSERTROW_BEFORE, String( "Insert before current", RTL_TEXTENCODING_IBM_850 ) ); 535 aRowMenu.InsertItem( MID_INSERTROW_AT, String( "~Insert at current", RTL_TEXTENCODING_IBM_850 ) ); 536 aRowMenu.InsertItem( MID_INSERTROW_BEHIND, String( "~Insert behind current", RTL_TEXTENCODING_IBM_850 ) ); 537 aRowMenu.InsertSeparator(); 538 aRowMenu.InsertItem( MID_REMOVEROW_BEFORE, String( "Remove before current", RTL_TEXTENCODING_IBM_850 ) ); 539 aRowMenu.InsertItem( MID_REMOVEROW_AT, String( "~Remove at current", RTL_TEXTENCODING_IBM_850 ) ); 540 aRowMenu.InsertItem( MID_REMOVEROW_BEHIND, String( "~Remove behind current", RTL_TEXTENCODING_IBM_850 ) ); 541 aRowMenu.InsertSeparator(); 542 aRowMenu.InsertItem( MID_MODIFYROW_BEFORE, String( "Modify before current", RTL_TEXTENCODING_IBM_850 ) ); 543 aRowMenu.InsertItem( MID_MODIFYROW_AT, String( "~Modify at current", RTL_TEXTENCODING_IBM_850 ) ); 544 aRowMenu.InsertItem( MID_MODIFYROW_BEHIND, String( "~Modify behind current", RTL_TEXTENCODING_IBM_850 ) ); 545 aMenu.InsertItem( MID_COL, String( "~Column", RTL_TEXTENCODING_IBM_850 ) ); 546 aMenu.SetPopupMenu( MID_COL, &aColMenu ); 547 aColMenu.InsertItem( MID_INSERTCOL, String( "~Insert", RTL_TEXTENCODING_IBM_850 ) ); 548 aColMenu.InsertItem( MID_REMOVECOL, String( "Re~move", RTL_TEXTENCODING_IBM_850 ) ); 549 aColMenu.InsertItem( MID_MOVECOLLEFT, String( "Move ~Left", RTL_TEXTENCODING_IBM_850 ) ); 550 aColMenu.InsertItem( MID_MOVECOLRIGHT, String( "Move ~Right", RTL_TEXTENCODING_IBM_850 ) ); 551 aMenu.InsertItem( MID_SELECTIONS, String( "Selections", RTL_TEXTENCODING_IBM_850 ) ); 552 aMenu.SetPopupMenu( MID_SELECTIONS, &aSelMenu ); 553 aSelMenu.InsertItem( MID_SELECTROW, String( "Row", RTL_TEXTENCODING_IBM_850 ) ); 554 aSelMenu.InsertItem( MID_SELECTALL, String( "All", RTL_TEXTENCODING_IBM_850 ) ); 555 aSelMenu.InsertItem( MID_SELECTNONE, String( "None", RTL_TEXTENCODING_IBM_850 ) ); 556 aSelMenu.InsertItem( MID_INVERSE, String( "Inverse", RTL_TEXTENCODING_IBM_850 ), MENU_APPEND, MIB_CHECKABLE ); 557 aMenu.InsertItem( MID_EXTRAS, String( "Extras", RTL_TEXTENCODING_IBM_850 ) ); 558 aMenu.SetPopupMenu( MID_EXTRAS, &aExtMenu ); 559 aExtMenu.InsertItem( MID_STARMONEY_1, String( "StarMoney: SelectRow(+1)+DeleteRow", RTL_TEXTENCODING_IBM_850 ) ); 560 aMenu.PushSelectHdl( LINK(this, AppWindow, MenuSelect) ); 561 562 aEdit.SetModifyHdl( LINK(this,AppWindow,Modify) ); 563 564 aEdit.Show(); 565 aBrowser.Show(); 566 Show(); 567 } 568 569 //------------------------------------------------------------------ 570 571 AppWindow::~AppWindow() 572 { 573 GetpApp()->SetAppMenu( 0 ); 574 if ( pEventView ) 575 delete pEventView; 576 } 577 578 //------------------------------------------------------------------ 579 580 IMPL_LINK_INLINE_START( AppWindow, Modify, void *, pCaller ) 581 { 582 Edit *pEdit = (Edit*) pCaller; 583 aBrowser.GoToRow( pEdit->GetText().ToInt32() ); 584 aBrowser.GrabFocus(); 585 586 return sal_True; 587 } 588 IMPL_LINK_INLINE_END( AppWindow, Modify, void *, pCaller ) 589 590 //------------------------------------------------------------------ 591 592 IMPL_LINK( AppWindow, MenuSelect, Menu *, pMenu ) 593 { 594 sal_uLong nPos; 595 596 switch ( pMenu->GetCurItemId() ) 597 { 598 case MID_MODE: 599 { 600 BrowseModeDialog *pDlg = new BrowseModeDialog( this ); 601 pDlg->SetMode( eCurMode ); 602 if ( pDlg->Execute() == RET_OK ) 603 { 604 eCurMode = pDlg->GetMode(); 605 aBrowser.SetMode( eCurMode | BROWSER_AUTOSIZE_LASTCOL ); 606 } 607 delete pDlg; 608 break; 609 } 610 611 case MID_INVALIDATE: 612 aBrowser.Invalidate(); 613 break; 614 615 case MID_INSERTROW_BEFORE: 616 if ( aBrowser.GetCurRow() == 0 ) 617 { 618 Sound::Beep(); 619 break; 620 } 621 nPos = aBrowser.GetCurRow() - 1; 622 aBrowser.aRows.Insert( nNewRowNo++, nPos ); 623 aBrowser.RowInserted( aBrowser.GetCurRow()-1 ); 624 break; 625 626 case MID_INSERTROW_AT: 627 nPos = aBrowser.GetCurRow(); 628 if ( nPos == BROWSER_ENDOFSELECTION ) 629 nPos = 0; 630 aBrowser.aRows.Insert( nNewRowNo++, nPos ); 631 aBrowser.RowInserted( nPos ); 632 break; 633 634 case MID_INSERTROW_BEHIND: 635 nPos = aBrowser.GetCurRow() + 1; 636 aBrowser.aRows.Insert( nNewRowNo++, nPos ); 637 aBrowser.RowInserted( nPos ); 638 break; 639 640 case MID_REMOVEROW_BEFORE: 641 if ( aBrowser.GetCurRow() == 0 ) 642 { 643 Sound::Beep(); 644 break; 645 } 646 nPos = aBrowser.GetCurRow() - 1; 647 aBrowser.aRows.Remove( nPos ); 648 aBrowser.RowRemoved( nPos ); 649 break; 650 651 case MID_REMOVEROW_AT: 652 nPos = aBrowser.GetCurRow(); 653 aBrowser.aRows.Remove( nPos ); 654 aBrowser.RowRemoved( nPos ); 655 break; 656 657 case MID_REMOVEROW_BEHIND: 658 if ( (aBrowser.GetCurRow()+1) >= aBrowser.GetRowCount() ) 659 { 660 Sound::Beep(); 661 break; 662 } 663 nPos = aBrowser.GetCurRow() + 1; 664 aBrowser.aRows.Remove( nPos ); 665 aBrowser.RowRemoved( nPos ); 666 break; 667 668 case MID_MODIFYROW_BEFORE: 669 if ( aBrowser.GetCurRow() == 0 ) 670 { 671 Sound::Beep(); 672 break; 673 } 674 nPos = aBrowser.GetCurRow() - 1; 675 aBrowser.aRows.Replace( nNewRowNo++, nPos ); 676 aBrowser.RowModified( nPos ); 677 break; 678 679 case MID_MODIFYROW_AT: 680 nPos = aBrowser.GetCurRow(); 681 aBrowser.aRows.Replace( nNewRowNo++, nPos ); 682 aBrowser.RowModified( nPos ); 683 break; 684 685 case MID_MODIFYROW_BEHIND: 686 if ( (aBrowser.GetCurRow()+1) >= aBrowser.GetRowCount() ) 687 { 688 Sound::Beep(); 689 break; 690 } 691 nPos = aBrowser.GetCurRow() + 1; 692 aBrowser.aRows.Replace( nNewRowNo++, nPos ); 693 aBrowser.RowModified( nPos ); 694 break; 695 696 case MID_EVENTVIEW: 697 if ( pEventView ) 698 { 699 delete pEventView; 700 pEventView = 0; 701 } 702 else 703 { 704 pEventView = new FloatingWindow( this ); 705 pEventView->SetPosPixel( Point( 100, 100 ) ); 706 pEventView->SetOutputSizePixel( 707 Size( 320, 8*GetTextHeight() ) ); 708 pEventView->Show(); 709 aBrowser.CursorMoved(); 710 aBrowser.Select(); 711 } 712 break; 713 714 case MID_SELECTROW: 715 aBrowser.SelectRow( aBrowser.GetCurRow(), 716 !aBrowser.IsRowSelected( aBrowser.GetCurRow() ) ); 717 break; 718 719 case MID_SELECTALL: 720 aBrowser.SelectAll(); 721 break; 722 723 case MID_SELECTNONE: 724 aBrowser.SetNoSelection(); 725 break; 726 727 case MID_INVERSE: 728 { 729 sal_Bool bChecked = pMenu->IsItemChecked( MID_INVERSE ); 730 pMenu->CheckItem( MID_INVERSE, !bChecked ); 731 aBrowser.SetInverseSelection( !bChecked ); 732 break; 733 } 734 735 case MID_CLEAR: 736 aBrowser.Clear(); 737 break; 738 739 case MID_STARMONEY_1: 740 { 741 nPos = aBrowser.GetCurRow(); 742 aBrowser.SelectRow( nPos + 1, sal_True ); 743 aBrowser.aRows.Remove( nPos ); 744 aBrowser.RowRemoved( nPos ); 745 break; 746 } 747 } 748 749 return sal_True; 750 } 751 752 //------------------------------------------------------------------ 753 754 void AppWindow::Resize() 755 { 756 Size aOutSz( GetOutputSizePixel() ); 757 758 aEdit.SetPosSizePixel( 759 Point( 0, 0 ), 760 Size( aOutSz.Width(), 24 ) ); 761 762 aBrowser.SetPosSizePixel( 763 Point( 0, aEdit.GetSizePixel().Height() ), 764 Size( aOutSz.Width(), aOutSz.Height() - 24 ) ); 765 } 766 767 //------------------------------------------------------------------ 768 769 void AppWindow::Activate() 770 { 771 GetpApp()->SetAppMenu( &aMenu ); 772 aBrowser.GrabFocus(); 773 } 774 775 //------------------------------------------------------------------ 776 777 void AppWindow::Event( const String &rEvent ) 778 { 779 if ( pEventView ) 780 { 781 pEventView->Scroll( 0, -GetTextHeight() ); 782 pEventView->Update(); 783 pEventView->DrawText( Point(0, 7*GetTextHeight() ), rEvent ); 784 } 785 } 786 787 //================================================================== 788 789 App::App() 790 { 791 } 792 793 //------------------------------------------------------------------ 794 795 App::~App() 796 { 797 } 798 799 //------------------------------------------------------------------ 800 801 void App::Main( ) 802 { 803 EnableSVLook(); 804 805 AppWindow aAppWin; 806 807 808 Execute(); 809 } 810 811