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