merge the formfield patch from ooo-build
[ooovba.git] / svtools / workben / browser.cxx
blob264257a6e7ef110de4944c7990da3532f89f91fd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: browser.cxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
33 #include <vcl/svapp.hxx>
34 #include <vcl/sound.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <vcl/floatwin.hxx>
37 #include <vcl/menu.hxx>
38 #include <vcl/wrkwin.hxx>
39 #include <vcl/edit.hxx>
40 #include <svtools/brwbox.hxx>
41 #include <vcl/group.hxx>
43 #ifndef _SV_BUTTON_HXX //autogen
44 #include <vcl/button.hxx>
45 #endif
46 #include <vcl/dialog.hxx>
48 #define MID_BROWSER 10
49 #define MID_MODE 11
50 #define MID_EVENTVIEW 12
51 #define MID_INVALIDATE 13
52 #define MID_CLEAR 14
53 #define MID_ROW 20
54 #define MID_INSERTROW_BEFORE 21
55 #define MID_INSERTROW_AT 22
56 #define MID_INSERTROW_BEHIND 23
57 #define MID_REMOVEROW_BEFORE 24
58 #define MID_REMOVEROW_AT 25
59 #define MID_REMOVEROW_BEHIND 26
60 #define MID_MODIFYROW_BEFORE 27
61 #define MID_MODIFYROW_AT 28
62 #define MID_MODIFYROW_BEHIND 29
63 #define MID_COL 30
64 #define MID_INSERTCOL 31
65 #define MID_REMOVECOL 32
66 #define MID_MOVECOLLEFT 33
67 #define MID_MOVECOLRIGHT 34
68 #define MID_SELECTIONS 60
69 #define MID_SELECTROW 61
70 #define MID_SELECTALL 62
71 #define MID_SELECTNONE 63
72 #define MID_INVERSE 64
73 #define MID_EXTRAS 70
74 #define MID_STARMONEY_1 71
76 //==================================================================
78 class BrowseModeDialog: public ModalDialog
80 RadioButton aSingleSel;
81 RadioButton aMultiSel;
82 GroupBox aSelGroup;
84 CheckBox aKeepHighlight;
85 CheckBox aColumnCursor;
86 CheckBox aThumbDragging;
87 GroupBox aOptGroup;
89 RadioButton aNoHLines;
90 RadioButton aDottedHLines;
91 RadioButton aFullHLines;
92 GroupBox aHLinGroup;
94 RadioButton aNoVLines;
95 RadioButton aDottedVLines;
96 RadioButton aFullVLines;
97 GroupBox aVLinGroup;
99 OKButton aOKButton;
100 CancelButton aCancelButton;
102 public:
103 BrowseModeDialog( Window *pParent );
105 void SetMode( BrowserMode eMode );
106 BrowserMode GetMode() const;
109 //==================================================================
111 DECLARE_LIST(DataList,long);
113 class Browser: public BrowseBox
115 friend class AppWindow;
117 DataList aRows;
118 BOOL bInverse;
119 Edit* pEdit;
121 protected:
122 virtual long GetRowCount() const;
123 virtual BOOL SeekRow( long nRow );
124 virtual void PaintField( OutputDevice& rDev, const Rectangle& rRect,
125 USHORT nColumnId ) const;
127 virtual void Select();
128 virtual void DoubleClick();
129 virtual void CursorMoved();
130 virtual void StartScroll();
131 virtual void EndScroll();
132 virtual void Command( const CommandEvent &eEvt );
134 virtual BOOL StartDragging( Pointer& rMovePtr,
135 Pointer& rCopyPtr );
136 virtual void EndDragging( const DropAction &rAction );
137 virtual void MouseButtonDown( const BrowserMouseEvent &rEvt );
139 public:
140 Browser( AppWindow* pParent, BrowserMode eMode );
141 ~Browser();
143 void SetInverseSelection( BOOL bInverseSel )
144 { bInverse = bInverseSel; }
147 //------------------------------------------------------------------
149 class AppWindow: public WorkWindow
151 MenuBar aMenu;
152 PopupMenu aBrwMenu, aRowMenu, aColMenu, aSelMenu, aExtMenu;
153 Edit aEdit;
154 Browser aBrowser;
155 BrowserMode eCurMode;
156 FloatingWindow *pEventView;
157 ULONG nNewRowNo;
159 private:
160 DECL_LINK( Modify, void * );
161 DECL_LINK( MenuSelect, Menu * );
163 protected:
164 void Resize();
165 void Activate();
167 public:
168 AppWindow();
169 ~AppWindow();
171 void Event( const String &rEvent );
174 //------------------------------------------------------------------
176 class App: public Application
178 protected:
179 void Main();
181 public:
182 App();
183 ~App();
186 //==================================================================
188 App aApp;
190 //==================================================================
192 BrowseModeDialog::BrowseModeDialog( Window *pParent ):
193 ModalDialog( pParent, WinBits( WB_MOVEABLE | WB_CLOSEABLE | WB_3DLOOK ) ),
195 aSingleSel( this ),
196 aMultiSel( this ),
197 aSelGroup( this ),
199 aKeepHighlight( this ),
200 aColumnCursor( this ),
201 aThumbDragging( this ),
202 aOptGroup( this ),
204 aNoHLines( this ),
205 aDottedHLines( this ),
206 aFullHLines( this ),
207 aHLinGroup( this ),
209 aNoVLines( this, WinBits( WB_GROUP ) ),
210 aDottedVLines( this ),
211 aFullVLines( this ),
212 aVLinGroup( this ),
214 aOKButton( this ),
215 aCancelButton( this )
217 SetOutputSizePixel( Size( 290, 220 ) );
218 SetText( String( "Browse Mode", RTL_TEXTENCODING_IBM_850 ) );
220 aSingleSel.SetText( String( "single", RTL_TEXTENCODING_IBM_850 ) );
221 aMultiSel.SetText( String( "multi", RTL_TEXTENCODING_IBM_850 ) );
222 aSelGroup.SetText( String( " Selection ", RTL_TEXTENCODING_IBM_850 ) );
224 aKeepHighlight.SetText( String( "keep highlight", RTL_TEXTENCODING_IBM_850 ) );
225 aColumnCursor.SetText( String( "column cursor", RTL_TEXTENCODING_IBM_850 ) );
226 aThumbDragging.SetText( String( "thumb dragging", RTL_TEXTENCODING_IBM_850 ) );
227 aOptGroup.SetText( String( " Options ", RTL_TEXTENCODING_IBM_850 ) );
229 aNoHLines.SetText( String( "none", RTL_TEXTENCODING_IBM_850 ) );
230 aDottedHLines.SetText( String( "dotted", RTL_TEXTENCODING_IBM_850 ) );
231 aFullHLines.SetText( String( "full", RTL_TEXTENCODING_IBM_850 ) );
232 aHLinGroup.SetText( String( " Horizontal ", RTL_TEXTENCODING_IBM_850 ) );
234 aNoVLines.SetText( String( "none", RTL_TEXTENCODING_IBM_850 ) );
235 aDottedVLines.SetText( String( "dotted", RTL_TEXTENCODING_IBM_850 ) );
236 aFullVLines.SetText( String( "full", RTL_TEXTENCODING_IBM_850 ) );
237 aVLinGroup.SetText( String( " Vertical ", RTL_TEXTENCODING_IBM_850 ) );
239 aSingleSel.SetPosSizePixel( Point( 20, 30 ), Size( 80, 14 ) );
240 aMultiSel.SetPosSizePixel( Point( 20, 70 ), Size( 80, 14 ) );
241 aSelGroup.SetPosSizePixel( Point( 10, 10 ), Size( 100, 80 ) );
242 aSelGroup.SetText( String( " Selection ", RTL_TEXTENCODING_IBM_850 ) );
244 aKeepHighlight.SetPosSizePixel( Point( 130, 30 ), Size( 140, 14 ) );
245 aColumnCursor.SetPosSizePixel( Point( 130, 50 ), Size( 140, 14 ) );
246 aThumbDragging.SetPosSizePixel( Point( 130, 70 ), Size( 140, 14 ) );
247 aOptGroup.SetPosSizePixel( Point( 120, 10 ), Size( 160, 80 ) );
248 aOptGroup.SetText( String( " Options ", RTL_TEXTENCODING_IBM_850 ) );
250 aNoHLines.SetPosSizePixel( Point( 20, 120 ), Size( 80, 14 ) );
251 aDottedHLines.SetPosSizePixel( Point( 20, 140 ), Size( 80, 14 ) );
252 aFullHLines.SetPosSizePixel( Point( 20, 160 ), Size( 80, 14 ) );
253 aHLinGroup.SetPosSizePixel( Point( 10, 100 ), Size( 100, 80 ) );
254 aHLinGroup.SetText( String( " horizontal ", RTL_TEXTENCODING_IBM_850 ) );
256 aNoVLines.SetPosSizePixel( Point( 130, 120 ), Size( 80, 14 ) );
257 aDottedVLines.SetPosSizePixel( Point( 130, 140 ), Size( 80, 14 ) );
258 aFullVLines.SetPosSizePixel( Point( 130, 160 ), Size( 80, 14 ) );
259 aVLinGroup.SetPosSizePixel( Point( 120, 100 ), Size( 100, 80 ) );
260 aVLinGroup.SetText( String( " vertical ", RTL_TEXTENCODING_IBM_850 ) );
262 aOKButton.SetPosSizePixel( Point( 10, 190 ), Size( 100, 22 ) );
263 aCancelButton.SetPosSizePixel( Point( 120, 190 ), Size( 100, 22 ) );
265 aSingleSel.Check();
266 aNoHLines.Check();
267 aNoVLines.Check();
269 aSingleSel.Show();
270 aMultiSel.Show();
271 aSelGroup.Show();
273 aKeepHighlight.Show();
274 aColumnCursor.Show();
275 aThumbDragging.Show();
276 aOptGroup.Show();
278 aNoHLines.Show();
279 aDottedHLines.Show();
280 aFullHLines.Show();
281 aHLinGroup.Show();
283 aNoVLines.Show();
284 aDottedVLines.Show();
285 aFullVLines.Show();
286 aVLinGroup.Show();
288 aOKButton.Show();
289 aCancelButton.Show();
292 //------------------------------------------------------------------
294 void BrowseModeDialog::SetMode( BrowserMode eMode )
296 if ( ( eMode & BROWSER_COLUMNSELECTION ) == BROWSER_COLUMNSELECTION )
297 aColumnCursor.Check();
298 if ( ( eMode & BROWSER_MULTISELECTION ) == BROWSER_MULTISELECTION )
299 aMultiSel.Check();
300 if ( ( eMode & BROWSER_THUMBDRAGGING ) == BROWSER_THUMBDRAGGING )
301 aThumbDragging.Check();
302 if ( ( eMode & BROWSER_KEEPHIGHLIGHT ) == BROWSER_KEEPHIGHLIGHT )
303 aKeepHighlight.Check();
304 if ( ( eMode & BROWSER_HLINESFULL ) == BROWSER_HLINESFULL )
305 aFullHLines.Check();
306 if ( ( eMode & BROWSER_VLINESFULL ) == BROWSER_VLINESFULL )
307 aFullVLines.Check();
308 if ( ( eMode & BROWSER_HLINESDOTS ) == BROWSER_HLINESDOTS )
309 aDottedHLines.Check();
310 if ( ( eMode & BROWSER_VLINESDOTS ) == BROWSER_VLINESDOTS )
311 aDottedVLines.Check();
314 //------------------------------------------------------------------
316 BrowserMode BrowseModeDialog::GetMode() const
318 BrowserMode eMode = 0;
320 if ( aColumnCursor.IsChecked() )
321 eMode |= BROWSER_COLUMNSELECTION;
322 if ( aMultiSel.IsChecked() )
323 eMode |= BROWSER_MULTISELECTION;
325 if ( aKeepHighlight.IsChecked() )
326 eMode |= BROWSER_KEEPHIGHLIGHT;
327 if ( aThumbDragging.IsChecked() )
328 eMode |= BROWSER_THUMBDRAGGING;
330 if ( aDottedHLines.IsChecked() )
331 eMode |= BROWSER_HLINESDOTS;
332 if ( aFullHLines.IsChecked() )
333 eMode |= BROWSER_HLINESFULL;
335 if ( aDottedVLines.IsChecked() )
336 eMode |= BROWSER_VLINESDOTS;
337 if ( aFullVLines.IsChecked() )
338 eMode |= BROWSER_VLINESFULL;
340 return eMode;
343 //==================================================================
345 Browser::Browser( AppWindow* pParent, BrowserMode eMode ):
346 BrowseBox( pParent, WinBits(WB_DRAG), eMode ),
347 bInverse(FALSE),
348 pEdit( 0 )
350 for ( long n = 0; n < 100; ++n )
351 aRows.Insert( n, LIST_APPEND );
353 //InsertHandleColumn( 30 );
354 InsertDataColumn( 1, String( "eins", RTL_TEXTENCODING_IBM_850 ), 85 ); // FreezeColumn( 1 );
355 InsertDataColumn( 2, String( "zwei", RTL_TEXTENCODING_IBM_850 ), 85 ); // FreezeColumn( 2 );
356 InsertDataColumn( 3, String( "drei", RTL_TEXTENCODING_IBM_850 ), 85 );
357 InsertDataColumn( 4, String( "vier", RTL_TEXTENCODING_IBM_850 ), 85 );
358 InsertDataColumn( 5, String( "fuenf", RTL_TEXTENCODING_IBM_850 ), 85 );
359 InsertDataColumn( 6, String( "sechs", RTL_TEXTENCODING_IBM_850 ), 85 );
360 InsertDataColumn( 7, String( "sieben", RTL_TEXTENCODING_IBM_850 ), 85 );
361 InsertDataColumn( 8, String( "acht", RTL_TEXTENCODING_IBM_850 ), 85 );
362 InsertDataColumn( 9, String( "neun", RTL_TEXTENCODING_IBM_850 ), 85 );
363 InsertDataColumn(10, String( "zehn", RTL_TEXTENCODING_IBM_850 ), 85 );
366 //------------------------------------------------------------------
368 Browser::~Browser()
370 delete pEdit;
373 //------------------------------------------------------------------
375 BOOL Browser::StartDragging( Pointer& rMovePtr, Pointer& rCopyPtr )
377 rMovePtr = Pointer( POINTER_MOVEDATA );
378 rCopyPtr = Pointer( POINTER_COPYDATA );
379 return TRUE;
382 //------------------------------------------------------------------
384 void Browser::MouseButtonDown( const BrowserMouseEvent &rEvt )
386 if ( 3 == rEvt.GetClicks() )
387 InfoBox( 0, String( GetColumnAtXPosPixel(rEvt.GetPosPixel().X() ) ) ).Execute();
388 else
389 BrowseBox::MouseButtonDown( rEvt );
392 //------------------------------------------------------------------
394 void Browser::EndDragging( const DropAction &rAction )
398 //------------------------------------------------------------------
400 void Browser::StartScroll()
402 ( (AppWindow*) GetParent() )->Event( String( "StartScroll", RTL_TEXTENCODING_IBM_850 ) );
403 if ( pEdit )
404 pEdit->Hide();
405 BrowseBox::StartScroll();
408 //------------------------------------------------------------------
410 void Browser::EndScroll()
412 BrowseBox::EndScroll();
413 ( (AppWindow*) GetParent() )->Event( String( "EndScroll", RTL_TEXTENCODING_IBM_850 ) );
414 if ( pEdit )
415 pEdit->Show();
417 //------------------------------------------------------------------
419 void Browser::Command( const CommandEvent &rEvt )
421 String aEvent( String( "Command at ", RTL_TEXTENCODING_IBM_850 ) );
422 aEvent += rEvt.GetMousePosPixel().X();
423 aEvent += String( ":", RTL_TEXTENCODING_IBM_850 );
424 aEvent += rEvt.GetMousePosPixel().Y();
425 ( (AppWindow*) GetParent() )->Event( aEvent );
426 BrowseBox::Command(rEvt);
429 //------------------------------------------------------------------
431 void Browser::Select()
433 String aEvent( String( "Select: ", RTL_TEXTENCODING_IBM_850 ) );
434 DELETEZ(pEdit);
435 for ( long nRow = FirstSelectedRow(bInverse); nRow >= 0; nRow = NextSelectedRow() )
437 if ( bInverse )
438 aEvent += String( String( "~", RTL_TEXTENCODING_IBM_850 ) );
439 aEvent += String( nRow );
440 aEvent += String( ", ", RTL_TEXTENCODING_IBM_850 );
442 aEvent.Erase( aEvent.Len() - 2 );
444 ( (AppWindow*) GetParent() )->Event( aEvent );
447 //------------------------------------------------------------------
449 void Browser::DoubleClick()
451 String aEvent( String( "DoubleClick: ", RTL_TEXTENCODING_IBM_850 ) );
452 aEvent += String( GetCurRow() );
453 aEvent += String( String( ", ", RTL_TEXTENCODING_IBM_850 ) );
454 aEvent += String( FirstSelectedRow() );
455 ( (AppWindow*) GetParent() )->Event( aEvent );
457 SetNoSelection();
458 if ( !pEdit )
459 pEdit = new Edit( &GetDataWindow() );
460 Rectangle aRect( GetFieldRect( GetCurColumnId() ) );
461 pEdit->SetPosSizePixel( aRect.TopLeft(), aRect.GetSize() );
462 pEdit->Show();
463 pEdit->GrabFocus();
466 //------------------------------------------------------------------
468 void Browser::CursorMoved()
470 String aEvent( String( "Cursor: ", RTL_TEXTENCODING_IBM_850 ) );
471 aEvent += String( GetCurRow() );
472 aEvent += String( ":", RTL_TEXTENCODING_IBM_850 );
473 aEvent += String( GetCurColumnId() );
474 ( (AppWindow*) GetParent() )->Event( aEvent );
475 if ( IsFieldVisible( GetCurRow(), GetCurColumnId(), TRUE ) )
476 ( (AppWindow*) GetParent() )->Event( String( "completely visible", RTL_TEXTENCODING_IBM_850 ) );
477 else if ( IsFieldVisible( 1, GetCurColumnId(), FALSE) )
478 ( (AppWindow*) GetParent() )->Event( String( "partly visible", RTL_TEXTENCODING_IBM_850 ) );
479 else
480 ( (AppWindow*) GetParent() )->Event( String( "not visible", RTL_TEXTENCODING_IBM_850 ) );
482 DELETEZ(pEdit);
485 //------------------------------------------------------------------
487 long Browser::GetRowCount() const
489 return aRows.Count();
492 //------------------------------------------------------------------
494 BOOL Browser::SeekRow( long nRow )
496 if ( nRow >= 0 && nRow < (long) aRows.Count() )
498 aRows.Seek(nRow);
499 return TRUE;
501 return FALSE;
504 //------------------------------------------------------------------
506 void Browser::PaintField( OutputDevice& rDev, const Rectangle& rRect,
507 USHORT nColumnId ) const
509 rDev.SetClipRegion( rRect );
510 String aText( aRows.GetCurObject() );
511 aText += String( ".", RTL_TEXTENCODING_IBM_850 );
512 aText += String( nColumnId );
513 rDev.DrawText( rRect.TopLeft(), aText );
516 //==================================================================
518 AppWindow::AppWindow():
519 WorkWindow( 0, WinBits(WB_APP|WB_STDWORK) ),
520 aEdit( this, WinBits( WB_BORDER ) ),
521 aBrowser( this, 0 ),
522 eCurMode( 0 ),
523 pEventView( 0 ),
524 nNewRowNo( 2000L )
526 SetText( String( "BrowseBox Testframe", RTL_TEXTENCODING_IBM_850 ) );
528 aMenu.InsertItem( MID_BROWSER, String( "~Browser", RTL_TEXTENCODING_IBM_850 ) );
529 aMenu.SetPopupMenu( MID_BROWSER, &aBrwMenu );
530 aBrwMenu.InsertItem( MID_MODE, String( "~Mode...", RTL_TEXTENCODING_IBM_850 ) );
531 aBrwMenu.InsertItem( MID_EVENTVIEW, String( "~Event-Viewer", RTL_TEXTENCODING_IBM_850 ) );
532 aBrwMenu.InsertSeparator();
533 aBrwMenu.InsertItem( MID_INVALIDATE, String( "~Invalidate", RTL_TEXTENCODING_IBM_850 ) );
534 aBrwMenu.InsertItem( MID_CLEAR, String( "~Clear", RTL_TEXTENCODING_IBM_850 ) );
535 aMenu.InsertItem( MID_ROW, String( "~Row", RTL_TEXTENCODING_IBM_850 ) );
536 aMenu.SetPopupMenu( MID_ROW, &aRowMenu );
537 aRowMenu.InsertItem( MID_INSERTROW_BEFORE, String( "Insert before current", RTL_TEXTENCODING_IBM_850 ) );
538 aRowMenu.InsertItem( MID_INSERTROW_AT, String( "~Insert at current", RTL_TEXTENCODING_IBM_850 ) );
539 aRowMenu.InsertItem( MID_INSERTROW_BEHIND, String( "~Insert behind current", RTL_TEXTENCODING_IBM_850 ) );
540 aRowMenu.InsertSeparator();
541 aRowMenu.InsertItem( MID_REMOVEROW_BEFORE, String( "Remove before current", RTL_TEXTENCODING_IBM_850 ) );
542 aRowMenu.InsertItem( MID_REMOVEROW_AT, String( "~Remove at current", RTL_TEXTENCODING_IBM_850 ) );
543 aRowMenu.InsertItem( MID_REMOVEROW_BEHIND, String( "~Remove behind current", RTL_TEXTENCODING_IBM_850 ) );
544 aRowMenu.InsertSeparator();
545 aRowMenu.InsertItem( MID_MODIFYROW_BEFORE, String( "Modify before current", RTL_TEXTENCODING_IBM_850 ) );
546 aRowMenu.InsertItem( MID_MODIFYROW_AT, String( "~Modify at current", RTL_TEXTENCODING_IBM_850 ) );
547 aRowMenu.InsertItem( MID_MODIFYROW_BEHIND, String( "~Modify behind current", RTL_TEXTENCODING_IBM_850 ) );
548 aMenu.InsertItem( MID_COL, String( "~Column", RTL_TEXTENCODING_IBM_850 ) );
549 aMenu.SetPopupMenu( MID_COL, &aColMenu );
550 aColMenu.InsertItem( MID_INSERTCOL, String( "~Insert", RTL_TEXTENCODING_IBM_850 ) );
551 aColMenu.InsertItem( MID_REMOVECOL, String( "Re~move", RTL_TEXTENCODING_IBM_850 ) );
552 aColMenu.InsertItem( MID_MOVECOLLEFT, String( "Move ~Left", RTL_TEXTENCODING_IBM_850 ) );
553 aColMenu.InsertItem( MID_MOVECOLRIGHT, String( "Move ~Right", RTL_TEXTENCODING_IBM_850 ) );
554 aMenu.InsertItem( MID_SELECTIONS, String( "Selections", RTL_TEXTENCODING_IBM_850 ) );
555 aMenu.SetPopupMenu( MID_SELECTIONS, &aSelMenu );
556 aSelMenu.InsertItem( MID_SELECTROW, String( "Row", RTL_TEXTENCODING_IBM_850 ) );
557 aSelMenu.InsertItem( MID_SELECTALL, String( "All", RTL_TEXTENCODING_IBM_850 ) );
558 aSelMenu.InsertItem( MID_SELECTNONE, String( "None", RTL_TEXTENCODING_IBM_850 ) );
559 aSelMenu.InsertItem( MID_INVERSE, String( "Inverse", RTL_TEXTENCODING_IBM_850 ), MENU_APPEND, MIB_CHECKABLE );
560 aMenu.InsertItem( MID_EXTRAS, String( "Extras", RTL_TEXTENCODING_IBM_850 ) );
561 aMenu.SetPopupMenu( MID_EXTRAS, &aExtMenu );
562 aExtMenu.InsertItem( MID_STARMONEY_1, String( "StarMoney: SelectRow(+1)+DeleteRow", RTL_TEXTENCODING_IBM_850 ) );
563 aMenu.PushSelectHdl( LINK(this, AppWindow, MenuSelect) );
565 aEdit.SetModifyHdl( LINK(this,AppWindow,Modify) );
567 aEdit.Show();
568 aBrowser.Show();
569 Show();
572 //------------------------------------------------------------------
574 AppWindow::~AppWindow()
576 GetpApp()->SetAppMenu( 0 );
577 if ( pEventView )
578 delete pEventView;
581 //------------------------------------------------------------------
583 IMPL_LINK_INLINE_START( AppWindow, Modify, void *, pCaller )
585 Edit *pEdit = (Edit*) pCaller;
586 aBrowser.GoToRow( pEdit->GetText().ToInt32() );
587 aBrowser.GrabFocus();
589 return TRUE;
591 IMPL_LINK_INLINE_END( AppWindow, Modify, void *, pCaller )
593 //------------------------------------------------------------------
595 IMPL_LINK( AppWindow, MenuSelect, Menu *, pMenu )
597 ULONG nPos;
599 switch ( pMenu->GetCurItemId() )
601 case MID_MODE:
603 BrowseModeDialog *pDlg = new BrowseModeDialog( this );
604 pDlg->SetMode( eCurMode );
605 if ( pDlg->Execute() == RET_OK )
607 eCurMode = pDlg->GetMode();
608 aBrowser.SetMode( eCurMode | BROWSER_AUTOSIZE_LASTCOL );
610 delete pDlg;
611 break;
614 case MID_INVALIDATE:
615 aBrowser.Invalidate();
616 break;
618 case MID_INSERTROW_BEFORE:
619 if ( aBrowser.GetCurRow() == 0 )
621 Sound::Beep();
622 break;
624 nPos = aBrowser.GetCurRow() - 1;
625 aBrowser.aRows.Insert( nNewRowNo++, nPos );
626 aBrowser.RowInserted( aBrowser.GetCurRow()-1 );
627 break;
629 case MID_INSERTROW_AT:
630 nPos = aBrowser.GetCurRow();
631 if ( nPos == BROWSER_ENDOFSELECTION )
632 nPos = 0;
633 aBrowser.aRows.Insert( nNewRowNo++, nPos );
634 aBrowser.RowInserted( nPos );
635 break;
637 case MID_INSERTROW_BEHIND:
638 nPos = aBrowser.GetCurRow() + 1;
639 aBrowser.aRows.Insert( nNewRowNo++, nPos );
640 aBrowser.RowInserted( nPos );
641 break;
643 case MID_REMOVEROW_BEFORE:
644 if ( aBrowser.GetCurRow() == 0 )
646 Sound::Beep();
647 break;
649 nPos = aBrowser.GetCurRow() - 1;
650 aBrowser.aRows.Remove( nPos );
651 aBrowser.RowRemoved( nPos );
652 break;
654 case MID_REMOVEROW_AT:
655 nPos = aBrowser.GetCurRow();
656 aBrowser.aRows.Remove( nPos );
657 aBrowser.RowRemoved( nPos );
658 break;
660 case MID_REMOVEROW_BEHIND:
661 if ( (aBrowser.GetCurRow()+1) >= aBrowser.GetRowCount() )
663 Sound::Beep();
664 break;
666 nPos = aBrowser.GetCurRow() + 1;
667 aBrowser.aRows.Remove( nPos );
668 aBrowser.RowRemoved( nPos );
669 break;
671 case MID_MODIFYROW_BEFORE:
672 if ( aBrowser.GetCurRow() == 0 )
674 Sound::Beep();
675 break;
677 nPos = aBrowser.GetCurRow() - 1;
678 aBrowser.aRows.Replace( nNewRowNo++, nPos );
679 aBrowser.RowModified( nPos );
680 break;
682 case MID_MODIFYROW_AT:
683 nPos = aBrowser.GetCurRow();
684 aBrowser.aRows.Replace( nNewRowNo++, nPos );
685 aBrowser.RowModified( nPos );
686 break;
688 case MID_MODIFYROW_BEHIND:
689 if ( (aBrowser.GetCurRow()+1) >= aBrowser.GetRowCount() )
691 Sound::Beep();
692 break;
694 nPos = aBrowser.GetCurRow() + 1;
695 aBrowser.aRows.Replace( nNewRowNo++, nPos );
696 aBrowser.RowModified( nPos );
697 break;
699 case MID_EVENTVIEW:
700 if ( pEventView )
702 delete pEventView;
703 pEventView = 0;
705 else
707 pEventView = new FloatingWindow( this );
708 pEventView->SetPosPixel( Point( 100, 100 ) );
709 pEventView->SetOutputSizePixel(
710 Size( 320, 8*GetTextHeight() ) );
711 pEventView->Show();
712 aBrowser.CursorMoved();
713 aBrowser.Select();
715 break;
717 case MID_SELECTROW:
718 aBrowser.SelectRow( aBrowser.GetCurRow(),
719 !aBrowser.IsRowSelected( aBrowser.GetCurRow() ) );
720 break;
722 case MID_SELECTALL:
723 aBrowser.SelectAll();
724 break;
726 case MID_SELECTNONE:
727 aBrowser.SetNoSelection();
728 break;
730 case MID_INVERSE:
732 BOOL bChecked = pMenu->IsItemChecked( MID_INVERSE );
733 pMenu->CheckItem( MID_INVERSE, !bChecked );
734 aBrowser.SetInverseSelection( !bChecked );
735 break;
738 case MID_CLEAR:
739 aBrowser.Clear();
740 break;
742 case MID_STARMONEY_1:
744 nPos = aBrowser.GetCurRow();
745 aBrowser.SelectRow( nPos + 1, TRUE );
746 aBrowser.aRows.Remove( nPos );
747 aBrowser.RowRemoved( nPos );
748 break;
752 return TRUE;
755 //------------------------------------------------------------------
757 void AppWindow::Resize()
759 Size aOutSz( GetOutputSizePixel() );
761 aEdit.SetPosSizePixel(
762 Point( 0, 0 ),
763 Size( aOutSz.Width(), 24 ) );
765 aBrowser.SetPosSizePixel(
766 Point( 0, aEdit.GetSizePixel().Height() ),
767 Size( aOutSz.Width(), aOutSz.Height() - 24 ) );
770 //------------------------------------------------------------------
772 void AppWindow::Activate()
774 GetpApp()->SetAppMenu( &aMenu );
775 aBrowser.GrabFocus();
778 //------------------------------------------------------------------
780 void AppWindow::Event( const String &rEvent )
782 if ( pEventView )
784 pEventView->Scroll( 0, -GetTextHeight() );
785 pEventView->Update();
786 pEventView->DrawText( Point(0, 7*GetTextHeight() ), rEvent );
790 //==================================================================
792 App::App()
796 //------------------------------------------------------------------
798 App::~App()
802 //------------------------------------------------------------------
804 void App::Main( )
806 EnableSVLook();
808 AppWindow aAppWin;
811 Execute();