summaryrefslogtreecommitdiff
path: root/svtools/source
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 16:07:07 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2000-09-18 16:07:07 +0000
commit8ab086b6cc054501bfbf7ef6fa509c393691e860 (patch)
tree324d51845d7f1a2f4e02a14db22fb5947137c822 /svtools/source
parent411e68cc54ae97eebd79ae3a9cb2971b74cb2a9e (diff)
initial import
Diffstat (limited to 'svtools/source')
-rw-r--r--svtools/source/brwbox/brwbox1.cxx2396
-rw-r--r--svtools/source/brwbox/brwbox2.cxx2021
-rw-r--r--svtools/source/brwbox/brwhead.cxx144
-rw-r--r--svtools/source/brwbox/datwin.cxx694
-rw-r--r--svtools/source/brwbox/datwin.hxx269
-rw-r--r--svtools/source/brwbox/makefile.mk99
-rw-r--r--svtools/source/config/makefile.mk82
-rw-r--r--svtools/source/config/pathoptions.cxx409
-rw-r--r--svtools/source/config/useroptions.cxx325
-rw-r--r--svtools/source/contnr/cont_pch.cxx73
-rw-r--r--svtools/source/contnr/ctrdll.cxx113
-rw-r--r--svtools/source/contnr/makefile.mk134
-rw-r--r--svtools/source/contnr/svicnvw.cxx855
-rw-r--r--svtools/source/contnr/svimpbox.cxx3171
-rw-r--r--svtools/source/contnr/svimpicn.cxx4222
-rw-r--r--svtools/source/contnr/svlbitm.cxx449
-rw-r--r--svtools/source/contnr/svlbox.cxx1691
-rw-r--r--svtools/source/contnr/svtabbx.cxx639
-rw-r--r--svtools/source/contnr/svtreebx.cxx2355
-rw-r--r--svtools/source/contnr/treelist.cxx2146
-rw-r--r--svtools/source/control/calendar.cxx2963
-rw-r--r--svtools/source/control/calendar.src166
-rw-r--r--svtools/source/control/ctrlbox.cxx1227
-rw-r--r--svtools/source/control/ctrlbox.src85
-rw-r--r--svtools/source/control/ctrldll.cxx112
-rw-r--r--svtools/source/control/ctrltool.cxx865
-rw-r--r--svtools/source/control/ctrltool.src425
-rw-r--r--svtools/source/control/filectrl.cxx307
-rw-r--r--svtools/source/control/filectrl.src85
-rw-r--r--svtools/source/control/fmtfield.cxx1017
-rw-r--r--svtools/source/control/headbar.cxx1673
-rw-r--r--svtools/source/control/makefile.mk141
-rw-r--r--svtools/source/control/prgsbar.cxx270
-rw-r--r--svtools/source/control/reginfo.cxx785
-rw-r--r--svtools/source/control/ruler.cxx3064
-rw-r--r--svtools/source/control/scrwin.cxx603
-rw-r--r--svtools/source/control/stdctrl.cxx77
-rw-r--r--svtools/source/control/stdmenu.cxx446
-rw-r--r--svtools/source/control/tabbar.cxx2588
-rw-r--r--svtools/source/control/taskbar.cxx645
-rw-r--r--svtools/source/control/taskbox.cxx406
-rw-r--r--svtools/source/control/taskmisc.cxx416
-rw-r--r--svtools/source/control/taskstat.cxx769
-rw-r--r--svtools/source/control/valueset.cxx2461
-rw-r--r--svtools/source/dialogs/colctrl.cxx814
-rw-r--r--svtools/source/dialogs/colrdlg.cxx358
-rw-r--r--svtools/source/dialogs/colrdlg.hrc101
-rw-r--r--svtools/source/dialogs/colrdlg.src576
-rw-r--r--svtools/source/dialogs/filedlg.cxx185
-rw-r--r--svtools/source/dialogs/filedlg2.cxx1377
-rw-r--r--svtools/source/dialogs/filedlg2.hrc75
-rw-r--r--svtools/source/dialogs/filedlg2.hxx255
-rw-r--r--svtools/source/dialogs/filedlg2.src422
-rw-r--r--svtools/source/dialogs/makefile.mk93
-rw-r--r--svtools/source/dialogs/mcvmath.cxx336
-rw-r--r--svtools/source/dialogs/mcvmath.hxx264
-rw-r--r--svtools/source/dialogs/printdlg.cxx527
-rw-r--r--svtools/source/dialogs/printdlg.hrc95
-rw-r--r--svtools/source/dialogs/printdlg.src616
-rw-r--r--svtools/source/dialogs/prnsetup.cxx444
-rw-r--r--svtools/source/dialogs/prnsetup.hrc78
-rw-r--r--svtools/source/dialogs/prnsetup.src966
-rw-r--r--svtools/source/dialogs/propctrl.cxx534
-rw-r--r--svtools/source/dialogs/property.cxx1582
-rw-r--r--svtools/source/dialogs/wizdlg.cxx678
-rw-r--r--svtools/source/edit/makefile.mk135
-rw-r--r--svtools/source/edit/svmedit.cxx1396
-rw-r--r--svtools/source/edit/sychconv.cxx139
-rw-r--r--svtools/source/edit/textdat2.hxx338
-rw-r--r--svtools/source/edit/textdata.cxx329
-rw-r--r--svtools/source/edit/textdoc.cxx1073
-rw-r--r--svtools/source/edit/textdoc.hxx202
-rw-r--r--svtools/source/edit/texteng.cxx2691
-rw-r--r--svtools/source/edit/textund2.hxx182
-rw-r--r--svtools/source/edit/textundo.cxx374
-rw-r--r--svtools/source/edit/textundo.hxx118
-rw-r--r--svtools/source/edit/textview.cxx1760
-rw-r--r--svtools/source/edit/txtattr.cxx157
-rw-r--r--svtools/source/edit/xtextedt.cxx444
-rw-r--r--svtools/source/filerec/filerec.cxx1039
-rw-r--r--svtools/source/filerec/makefile.mk85
-rw-r--r--svtools/source/filter.vcl/filter/dlgejpg.cxx129
-rw-r--r--svtools/source/filter.vcl/filter/dlgejpg.hrc73
-rw-r--r--svtools/source/filter.vcl/filter/dlgejpg.hxx105
-rw-r--r--svtools/source/filter.vcl/filter/dlgejpg.src266
-rw-r--r--svtools/source/filter.vcl/filter/dlgexpor.cxx517
-rw-r--r--svtools/source/filter.vcl/filter/dlgexpor.hrc92
-rw-r--r--svtools/source/filter.vcl/filter/dlgexpor.hxx152
-rw-r--r--svtools/source/filter.vcl/filter/dlgexpor.src809
-rw-r--r--svtools/source/filter.vcl/filter/filter.cxx2735
-rw-r--r--svtools/source/filter.vcl/filter/filter2.cxx1427
-rw-r--r--svtools/source/filter.vcl/filter/fldll.cxx110
-rw-r--r--svtools/source/filter.vcl/filter/gradwrap.cxx619
-rw-r--r--svtools/source/filter.vcl/filter/makefile.mk137
-rw-r--r--svtools/source/filter.vcl/filter/sgf.ini118
-rw-r--r--svtools/source/filter.vcl/filter/sgfbram.cxx696
-rw-r--r--svtools/source/filter.vcl/filter/sgvmain.cxx1220
-rw-r--r--svtools/source/filter.vcl/filter/sgvspln.cxx1115
-rw-r--r--svtools/source/filter.vcl/filter/sgvtext.cxx1370
-rw-r--r--svtools/source/filter.vcl/filter/strings.hrc61
-rw-r--r--svtools/source/filter.vcl/filter/strings.src117
-rw-r--r--svtools/source/filter.vcl/igif/decode.cxx245
-rw-r--r--svtools/source/filter.vcl/igif/decode.hxx102
-rw-r--r--svtools/source/filter.vcl/igif/gifread.cxx890
-rw-r--r--svtools/source/filter.vcl/igif/makefile.mk96
-rw-r--r--svtools/source/filter.vcl/ixbm/makefile.mk95
-rw-r--r--svtools/source/filter.vcl/ixbm/xbmread.cxx429
-rw-r--r--svtools/source/filter.vcl/ixpm/makefile.mk95
-rw-r--r--svtools/source/filter.vcl/ixpm/rgbtable.hxx729
-rw-r--r--svtools/source/filter.vcl/ixpm/xpmread.cxx714
-rw-r--r--svtools/source/filter.vcl/jpeg/jpeg.cxx565
-rw-r--r--svtools/source/filter.vcl/jpeg/makefile.mk96
-rw-r--r--svtools/source/filter.vcl/wmf/emfwr.cxx1207
-rw-r--r--svtools/source/filter.vcl/wmf/emfwr.hxx129
-rw-r--r--svtools/source/filter.vcl/wmf/enhwmf.cxx1077
-rw-r--r--svtools/source/filter.vcl/wmf/makefile.mk97
-rw-r--r--svtools/source/filter.vcl/wmf/winmtf.cxx1262
-rw-r--r--svtools/source/filter.vcl/wmf/winmtf.hxx687
-rw-r--r--svtools/source/filter.vcl/wmf/winwmf.cxx886
-rw-r--r--svtools/source/filter.vcl/wmf/wmf.cxx147
-rw-r--r--svtools/source/filter.vcl/wmf/wmfwr.cxx1787
-rw-r--r--svtools/source/filter.vcl/wmf/wmfwr.hxx245
-rw-r--r--svtools/source/items/aeitem.cxx296
-rw-r--r--svtools/source/items/eitem.cxx81
-rw-r--r--svtools/source/items/flagitem.cxx205
-rw-r--r--svtools/source/items/intitem.cxx306
-rw-r--r--svtools/source/items/itemdel.cxx175
-rw-r--r--svtools/source/items/macitem.cxx395
-rw-r--r--svtools/source/items/makefile.mk176
-rw-r--r--svtools/source/items/poolcach.cxx186
-rw-r--r--svtools/source/items/ptitem.cxx204
-rw-r--r--svtools/source/items/rectitem.cxx211
-rw-r--r--svtools/source/items/rngitem.cxx383
-rw-r--r--svtools/source/items/stritem.cxx106
-rw-r--r--svtools/source/items/style.cxx1201
-rw-r--r--svtools/source/items/szitem.cxx214
-rw-r--r--svtools/source/items/wallitem.cxx694
-rw-r--r--svtools/source/memtools/makefile.mk118
-rw-r--r--svtools/source/memtools/svarray.cxx415
-rw-r--r--svtools/source/misc/config.src1005
-rw-r--r--svtools/source/misc/errtxt.src2778
-rw-r--r--svtools/source/misc/makefile.mk160
-rw-r--r--svtools/source/misc/urihelper.cxx683
-rw-r--r--svtools/source/misc/vcldata.cxx84
-rw-r--r--svtools/source/notify/brdcst.cxx281
-rw-r--r--svtools/source/notify/cancel.cxx221
-rw-r--r--svtools/source/notify/hint.cxx79
-rw-r--r--svtools/source/notify/isethint.cxx117
-rw-r--r--svtools/source/notify/lstner.cxx223
-rw-r--r--svtools/source/notify/makefile.mk123
-rw-r--r--svtools/source/notify/smplhint.cxx79
-rw-r--r--svtools/source/numbers/makefile.mk122
-rw-r--r--svtools/source/numbers/nbdll.cxx113
-rw-r--r--svtools/source/numbers/numfmuno.cxx1137
-rw-r--r--svtools/source/numbers/numfmuno.hxx364
-rw-r--r--svtools/source/numbers/numhead.cxx323
-rw-r--r--svtools/source/numbers/numhead.hxx142
-rw-r--r--svtools/source/numbers/numuno.cxx193
-rw-r--r--svtools/source/numbers/supservs.cxx264
-rw-r--r--svtools/source/numbers/supservs.hxx142
-rw-r--r--svtools/source/numbers/zforfind.cxx2316
-rw-r--r--svtools/source/numbers/zforlist.cxx3657
-rw-r--r--svtools/source/numbers/zformat.cxx3469
-rw-r--r--svtools/source/numbers/zforscan.cxx2406
-rw-r--r--svtools/source/numbers/zforscan.hxx254
-rw-r--r--svtools/source/plugapp/commtest.cxx303
-rw-r--r--svtools/source/plugapp/commtest.hrc68
-rw-r--r--svtools/source/plugapp/commtest.src94
-rw-r--r--svtools/source/plugapp/makefile.mk111
-rw-r--r--svtools/source/plugapp/testtool.hrc89
-rw-r--r--svtools/source/plugapp/testtool.src622
-rw-r--r--svtools/source/plugapp/ttprops.cxx119
-rw-r--r--svtools/source/svdde/ddecli.cxx509
-rw-r--r--svtools/source/svdde/ddedata.cxx253
-rw-r--r--svtools/source/svdde/ddedll.cxx96
-rw-r--r--svtools/source/svdde/ddeimp.hxx215
-rw-r--r--svtools/source/svdde/ddeinf.cxx212
-rw-r--r--svtools/source/svdde/ddeml1.cxx2689
-rw-r--r--svtools/source/svdde/ddeml2.cxx1157
-rw-r--r--svtools/source/svdde/ddemldeb.cxx311
-rw-r--r--svtools/source/svdde/ddemldeb.hxx100
-rw-r--r--svtools/source/svdde/ddemlimp.hxx467
-rw-r--r--svtools/source/svdde/ddemlos2.h411
-rw-r--r--svtools/source/svdde/ddestrg.cxx109
-rw-r--r--svtools/source/svdde/ddesvr.cxx1136
-rw-r--r--svtools/source/svdde/makefile.mk123
-rw-r--r--svtools/source/svhtml/htmlkey2.cxx700
-rw-r--r--svtools/source/svhtml/htmlkywd.cxx1099
-rw-r--r--svtools/source/svhtml/htmlout.cxx708
-rw-r--r--svtools/source/svhtml/htmlsupp.cxx205
-rw-r--r--svtools/source/svhtml/makefile.mk112
-rw-r--r--svtools/source/svhtml/parhtml.cxx2043
-rw-r--r--svtools/source/svrtf/makefile.mk105
-rw-r--r--svtools/source/svrtf/parrtf.cxx591
-rw-r--r--svtools/source/svrtf/rtfkey2.cxx1112
-rw-r--r--svtools/source/svrtf/rtfkeywd.cxx1198
-rw-r--r--svtools/source/svrtf/rtfkeywd.hxx1197
-rw-r--r--svtools/source/svrtf/rtfout.cxx224
-rw-r--r--svtools/source/svrtf/rtfout.hxx93
-rw-r--r--svtools/source/svrtf/rtftoken.h1304
-rw-r--r--svtools/source/svrtf/svparser.cxx692
-rw-r--r--svtools/source/svsql/converter.cxx75
-rw-r--r--svtools/source/svsql/converter.hxx76
-rw-r--r--svtools/source/svsql/makefile.mk124
-rw-r--r--svtools/source/undo/makefile.mk88
-rw-r--r--svtools/source/undo/undo.cxx988
-rw-r--r--svtools/source/uno/makefile.mk253
-rw-r--r--svtools/source/uno/registerservices.cxx187
-rw-r--r--svtools/source/uno/unoifac2.hrc86
-rw-r--r--svtools/source/uno/unoifac2.src223
-rw-r--r--svtools/source/uno/unoiface.cxx1756
-rw-r--r--svtools/source/urlobj/inetimg.cxx236
-rw-r--r--svtools/source/urlobj/makefile.mk89
213 files changed, 139028 insertions, 0 deletions
diff --git a/svtools/source/brwbox/brwbox1.cxx b/svtools/source/brwbox/brwbox1.cxx
new file mode 100644
index 000000000000..53c90ed1e64a
--- /dev/null
+++ b/svtools/source/brwbox/brwbox1.cxx
@@ -0,0 +1,2396 @@
+/*************************************************************************
+ *
+ * $RCSfile: brwbox1.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <brwbox.hxx>
+#include <tools/debug.hxx>
+#include <tools/stream.hxx>
+#include <vcl/sound.hxx>
+#include "brwhead.hxx"
+#include "datwin.hxx"
+
+#pragma hdrstop
+
+#ifndef _SV_MULTISEL_HXX
+#include <tools/multisel.hxx>
+#endif
+
+DBG_NAME(BrowseBox);
+
+extern const char* BrowseBoxCheckInvariants( const void* pVoid );
+
+DECLARE_LIST( BrowserColumns, BrowserColumn* );
+
+#ifdef VCL
+#define SCROLL_FLAGS (SCROLL_CLIP | SCROLL_NOCHILDREN)
+#else
+#define SCROLL_FLAGS TRUE
+#endif
+
+//-------------------------------------------------------------------
+
+#if DBG_MI
+void DoLog_Impl( const BrowseBox *pThis, const char *pWhat, const char *pWho )
+{
+ SvFileStream aLog( "d:\\cursor.log", STREAM_WRITE|STREAM_NOCREATE );
+ if ( aLog.IsOpen() )
+ {
+ aLog.Seek( STREAM_SEEK_TO_END );
+ String aEntry( (long) pThis );
+ aEntry += "(row=";
+ aEntry += pThis->GetCurRow();
+ aEntry += "): ";
+ aEntry += pWhat;
+ aEntry += " from ";
+ aEntry += pWho;
+ aEntry += " => ";
+ aEntry += pThis->GetCursorHideCount();
+ aLog.WriteLine( aEntry );
+ }
+}
+#endif
+
+//===================================================================
+
+void BrowseBox::Construct( BrowserMode nMode )
+{
+ DBG_TRACE1( "BrowseBox: %p->Construct", this );
+ bMultiSelection = FALSE;
+ pColSel = 0;
+ pDataWin = 0;
+ pVScroll = 0;
+
+ pDataWin = new BrowserDataWin( this );
+ pCols = new BrowserColumns;
+
+ aLineColor = Color( COL_LIGHTGRAY );
+ InitSettings_Impl( this );
+ InitSettings_Impl( pDataWin );
+
+ bBootstrapped = FALSE;
+ bHasBitmapHandle = FALSE;
+ nDataRowHeight = 0;
+ nTitleLines = 1;
+ nFirstCol = 0;
+ nTopRow = 0;
+ nCurRow = BROWSER_ENDOFSELECTION;
+ nCurColId = 0;
+ bResizing = FALSE;
+ bSelect = FALSE;
+ bSelecting = FALSE;
+ bScrolling = FALSE;
+ bSelectionIsVisible = FALSE;
+ bNotToggleSel = FALSE;
+ bDrag = FALSE;
+ bHit = FALSE;
+ bRubber = FALSE;
+ bHideSelect = FALSE;
+ bHideCursor = FALSE;
+ nRowCount = 0;
+ m_bFocusOnlyCursor = TRUE;
+ m_aCursorColor = COL_TRANSPARENT;
+ m_nCurrentMode = 0;
+
+ aHScroll.SetLineSize(1);
+ aHScroll.SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) );
+ aHScroll.SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) );
+ pDataWin->Show();
+
+ SetMode( nMode );
+ bSelectionIsVisible = bKeepHighlight;
+ bHasFocus = HasChildPathFocus();
+ ((BrowserDataWin*)pDataWin)->nCursorHidden =
+ ( bHasFocus ? 0 : 1 ) + ( GetUpdateMode() ? 0 : 1 );
+ LOG( this, "Construct", "*" );
+}
+
+//-------------------------------------------------------------------
+
+BrowseBox::BrowseBox( Window* pParent, WinBits nBits, BrowserMode nMode ) :
+ Control( pParent, nBits | WB_3DLOOK ),
+ aHScroll( this, WinBits( WB_HSCROLL ) )
+{
+ DBG_CTOR( BrowseBox, NULL );
+ Construct( nMode );
+}
+
+//-------------------------------------------------------------------
+
+BrowseBox::BrowseBox( Window* pParent, const ResId& rId, BrowserMode nMode ):
+ Control( pParent, rId ),
+ aHScroll( this, WinBits(WB_HSCROLL) )
+{
+ DBG_CTOR( BrowseBox, NULL );
+ Construct(nMode);
+}
+
+//-------------------------------------------------------------------
+
+BrowseBox::~BrowseBox()
+{
+ DBG_DTOR(BrowseBox,BrowseBoxCheckInvariants);
+ DBG_TRACE1( "BrowseBox: %p~", this );
+
+ Hide();
+ delete ((BrowserDataWin*)pDataWin)->pHeaderBar;
+ delete ((BrowserDataWin*)pDataWin)->pCornerWin;
+ delete pDataWin;
+ delete pVScroll;
+
+ // free columns-space
+ for ( USHORT n = 0; n < pCols->Count(); ++n )
+ delete pCols->GetObject(n);
+ delete pCols;
+ delete pColSel;
+ if ( bMultiSelection )
+ delete uRow.pSel;
+}
+
+//-------------------------------------------------------------------
+
+short BrowseBox::GetCursorHideCount() const
+{
+ return ((BrowserDataWin*)pDataWin)->nCursorHidden;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::DoShowCursor( const char *pWhoLogs )
+{
+ short nHiddenCount = --((BrowserDataWin*)pDataWin)->nCursorHidden;
+ if (PaintCursorIfHiddenOnce())
+ {
+ if (1 == nHiddenCount)
+ DrawCursor();
+ }
+ else
+ {
+ if (0 == nHiddenCount)
+ DrawCursor();
+ }
+ LOG( this, "DoShowCursor", pWhoLogs );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::DoHideCursor( const char *pWhoLogs )
+{
+ short nHiddenCount = ++((BrowserDataWin*)pDataWin)->nCursorHidden;
+ if (PaintCursorIfHiddenOnce())
+ {
+ if (2 == nHiddenCount)
+ DrawCursor();
+ }
+ else
+ {
+ if (1 == nHiddenCount)
+ DrawCursor();
+ }
+ LOG( this, "DoHideCursor", pWhoLogs );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetRealRowCount( const String &rRealRowCount )
+{
+ ((BrowserDataWin*)pDataWin)->aRealRowCount = rRealRowCount;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetMapMode( const MapMode& rNewMapMode )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ pDataWin->SetMapMode( rNewMapMode );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetFont( const Font& rNewFont )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ pDataWin->SetFont( rNewFont );
+ ImpGetDataRowHeight();
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::InsertHandleColumn( ULONG nWidth, BOOL bBitmap )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ pCols->Insert( new BrowserColumn( 0, Image(), String(), nWidth, GetZoom(), 0 ), (ULONG) 0 );
+ FreezeColumn( 0 );
+
+ // Headerbar anpassen
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetPosPixel(
+ Point(nWidth, 0));
+
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetSizePixel(
+ Size( GetOutputSizePixel().Width() - nWidth, GetTitleHeight() ) );
+ }
+
+ /*if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->InsertItem( USHRT_MAX - 1,
+ "", nWidth, HIB_FIXEDPOS|HIB_FIXED, 0 );*/
+ ColumnInserted( 0 );
+ bHasBitmapHandle = bBitmap;
+}
+
+//-------------------------------------------------------------------
+#if SUPD<380
+void BrowseBox::InsertDataColumn( USHORT nItemId, const String &rTitle,
+ ULONG nWidth, BrowserColumnMode nFlags, USHORT nPos )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ pCols->Insert( new BrowserColumn( nItemId, Image(), rTitle, nWidth, GetZoom(), nFlags ),
+ Min( nPos, (USHORT)(pCols->Count()) ) );
+ if ( nCurColId == 0 )
+ nCurColId = nItemId;
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->InsertItem(
+ nItemId, rTitle, nWidth, HIB_STDSTYLE, nPos );
+ ColumnInserted( nPos );
+}
+#else
+//-------------------------------------------------------------------
+
+void BrowseBox::InsertDataColumn( USHORT nItemId, const Image& rImage,
+ long nWidth, HeaderBarItemBits nBits, USHORT nPos )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ pCols->Insert( new BrowserColumn( nItemId, rImage, String(), nWidth, GetZoom(), nBits ),
+ Min( nPos, (USHORT)(pCols->Count()) ) );
+ if ( nCurColId == 0 )
+ nCurColId = nItemId;
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ // Handlecolumn nicht in der Headerbar
+ USHORT nHeaderPos = nPos;
+ if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0))
+ nHeaderPos--;
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->InsertItem(
+ nItemId, rImage, nWidth, nBits, nHeaderPos );
+ }
+ ColumnInserted( nPos );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::InsertDataColumn( USHORT nItemId, const XubString& rText,
+ long nWidth, HeaderBarItemBits nBits, USHORT nPos )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ pCols->Insert( new BrowserColumn( nItemId, Image(), rText, nWidth, GetZoom(), nBits ),
+ Min( nPos, (USHORT)(pCols->Count()) ) );
+ if ( nCurColId == 0 )
+ nCurColId = nItemId;
+
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ // Handlecolumn nicht in der Headerbar
+ USHORT nHeaderPos = nPos;
+ if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0))
+ nHeaderPos--;
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->InsertItem(
+ nItemId, rText, nWidth, nBits, nHeaderPos );
+ }
+ ColumnInserted( nPos );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::InsertDataColumn( USHORT nItemId,
+ const Image& rImage, const XubString& rText,
+ long nWidth, HeaderBarItemBits nBits, USHORT nPos,
+ const String* pHelpText )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ pCols->Insert( new BrowserColumn( nItemId, rImage, rText, nWidth, GetZoom(), nBits ),
+ Min( nPos, (USHORT)(pCols->Count()) ) );
+ if ( nCurColId == 0 )
+ nCurColId = nItemId;
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ // Handlecolumn nicht in der Headerbar
+ USHORT nHeaderPos = nPos;
+ if (nHeaderPos != HEADERBAR_APPEND && !GetColumnId(0))
+ nHeaderPos--;
+
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->InsertItem(
+ nItemId, rImage, rText, nWidth, nBits, nHeaderPos );
+ if( pHelpText && !rText.Len() )
+ {
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetHelpText(
+ nItemId, *pHelpText );
+ }
+ }
+ ColumnInserted( nPos );
+}
+#endif
+//-------------------------------------------------------------------
+
+void BrowseBox::FreezeColumn( USHORT nItemId, BOOL bFreeze )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // never unfreeze the handle-column
+ if ( nItemId == 0 && !bFreeze )
+ return;
+
+ // get the position in the current array
+ USHORT nItemPos = GetColumnPos( nItemId );
+ if ( nItemPos >= pCols->Count() )
+ // not available!
+ return;
+
+ // doesn't the state change?
+ if ( pCols->GetObject(nItemPos)->IsFrozen() == bFreeze )
+ return;
+
+ // remark the column selection
+ USHORT nSelectedColId = USHRT_MAX;
+ if ( pColSel && pColSel->GetSelectCount() )
+ {
+ DoHideCursor( "FreezeColumn" );
+ ToggleSelection();
+ nSelectedColId = pCols->GetObject(pColSel->FirstSelected())->GetId();
+ pColSel->SelectAll(FALSE);
+ }
+
+ // freeze or unfreeze?
+ if ( bFreeze )
+ {
+ // to be moved?
+ if ( nItemPos != 0 && !pCols->GetObject(nItemPos-1)->IsFrozen() )
+ {
+ // move to the right of the last frozen column
+ USHORT nFirstScrollable = FrozenColCount();
+ BrowserColumn *pColumn = pCols->GetObject(nItemPos);
+ pCols->Remove( (ULONG) nItemPos );
+ nItemPos = nFirstScrollable;
+ pCols->Insert( pColumn, (ULONG) nItemPos );
+ }
+
+ // adjust the number of the first scrollable and visible column
+ if ( nFirstCol <= nItemPos )
+ nFirstCol = nItemPos + 1;
+ }
+ else
+ {
+ // to be moved?
+ if ( nItemPos != FrozenColCount()-1 )
+ {
+ // move to the leftmost scrollable colum
+ USHORT nFirstScrollable = FrozenColCount();
+ BrowserColumn *pColumn = pCols->GetObject(nItemPos);
+ pCols->Remove( (ULONG) nItemPos );
+ nItemPos = nFirstScrollable;
+ pCols->Insert( pColumn, (ULONG) nItemPos );
+ }
+
+ // adjust the number of the first scrollable and visible column
+ nFirstCol = nItemPos;
+ }
+
+ // toggle the freeze-state of the column
+ pCols->GetObject(nItemPos)->Freeze( bFreeze );
+
+ // align the scrollbar-range
+ UpdateScrollbars();
+
+ // repaint
+ Control::Invalidate();
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+
+ // remember the column selection
+ if ( pColSel && nSelectedColId != USHRT_MAX )
+ {
+ pColSel->Select( GetColumnPos( nSelectedColId ) );
+ ToggleSelection();
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+ DoShowCursor( "FreezeColumn" );
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetColumnPos( USHORT nColumnId, USHORT nPos )
+{
+ // never set pos of the handle-column
+ if ( nColumnId == 0 )
+ return;
+
+ // do not move handle column
+ if (nPos == 0 && !pCols->GetObject(0)->GetId())
+ return;
+
+ // get the position in the current array
+ USHORT nOldPos = GetColumnPos( nColumnId );
+ if ( nOldPos >= pCols->Count() )
+ // not available!
+ return;
+
+ // does the state change?
+ BrowserColumn *pCol = pCols->GetObject(nOldPos);
+ if (nOldPos != nPos)
+ {
+ // determine old column area
+ Size aDataWinSize( pDataWin->GetSizePixel() );
+ Rectangle aFromRect( GetFieldRect( nColumnId) );
+
+ // move column internally
+ pCols->Insert( pCols->Remove( nOldPos ), nPos );
+
+ // determine new column area
+ Rectangle aToRect( GetFieldRect( nColumnId ) );
+
+ // do scroll, let redraw
+ Rectangle aForNewArea( Point( aToRect.Left(), 0 ),
+ Size( aDataWinSize.Width() - aToRect.Left(),
+ aDataWinSize.Height() ) );
+ Rectangle aForOldArea( Point( aFromRect.Right(), 0 ),
+ Size( aDataWinSize.Width() - aFromRect.Right(),
+ aDataWinSize.Height() ) );
+
+ if( pDataWin->GetBackground().IsScrollable() )
+ {
+ if ( nOldPos > nPos )
+ pDataWin->Scroll( -aFromRect.GetWidth()-4, 0, aForOldArea );
+ pDataWin->Scroll( aToRect.GetWidth()+4, 0, aForNewArea );
+ if ( nOldPos < nPos )
+ pDataWin->Scroll( -aFromRect.GetWidth()-4, 0, aForOldArea );
+ }
+ else
+ pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
+ }
+
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetColumnMode( USHORT nColumnId, BrowserColumnMode nFlags )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // never set mode of the handle-column
+ if ( nColumnId == 0 )
+ return;
+
+ // get the position in the current array
+ USHORT nColumnPos = GetColumnPos( nColumnId );
+ if ( nColumnPos >= pCols->Count() )
+ // not available!
+ return;
+
+ // does the state change?
+ BrowserColumn *pCol = pCols->GetObject(nColumnPos);
+ if ( pCol->Flags() != nFlags )
+ {
+ pCol->Flags() = nFlags;
+
+ // redraw visible colums
+ if ( GetUpdateMode() && ( pCol->IsFrozen() || nColumnPos > nFirstCol ) )
+ Invalidate( Rectangle( Point(0,0),
+ Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetColumnTitle( USHORT nItemId, const String& rTitle )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // never set title of the handle-column
+ if ( nItemId == 0 )
+ return;
+
+ // get the position in the current array
+ USHORT nItemPos = GetColumnPos( nItemId );
+ if ( nItemPos >= pCols->Count() )
+ // not available!
+ return;
+
+ // does the state change?
+ BrowserColumn *pCol = pCols->GetObject(nItemPos);
+ if ( pCol->Title() != rTitle )
+ {
+ pCol->Title() = rTitle;
+
+ // Headerbar-Column anpassen
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetItemText(
+ nItemId ? nItemId : USHRT_MAX - 1, rTitle );
+ else
+ {
+ // redraw visible colums
+ if ( GetUpdateMode() && ( pCol->IsFrozen() || nItemPos > nFirstCol ) )
+ Invalidate( Rectangle( Point(0,0),
+ Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
+ }
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetColumnWidth( USHORT nItemId, ULONG nWidth )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // get the position in the current array
+ USHORT nItemPos = GetColumnPos( nItemId );
+ if ( nItemPos >= pCols->Count() )
+ return;
+
+ // does the state change?
+ nWidth = QueryColumnResize( nItemId, nWidth );
+ if ( nWidth >= LONG_MAX || pCols->GetObject(nItemPos)->Width() != nWidth )
+ {
+ long nOldWidth = pCols->GetObject(nItemPos)->Width();
+
+ // ggf. letzte Spalte anpassen
+ if ( IsVisible() && nItemPos == pCols->Count() - 1 )
+ {
+ long nMaxWidth = pDataWin->GetSizePixel().Width();
+ nMaxWidth -= ((BrowserDataWin*)pDataWin)->bAutoSizeLastCol
+ ? GetFieldRect(nItemId).Left()
+ : GetFrozenWidth();
+ if ( ( (BrowserDataWin*)pDataWin )->bAutoSizeLastCol || nWidth > (ULONG)nMaxWidth )
+ {
+ nWidth = nMaxWidth > 16 ? nMaxWidth : nOldWidth;
+ nWidth = QueryColumnResize( nItemId, nWidth );
+ }
+ }
+
+ // OV
+ // In AutoSizeLastColumn() wird SetColumnWidth mit nWidth==0xffff
+ // gerufen. Deshalb muss hier nochmal geprueft werden, ob sich die
+ // Breite tatsaechlich geaendert hat.
+ if( (ULONG)nOldWidth == nWidth )
+ return;
+
+ // soll die Aenderung sofort dargestellt werden?
+ BOOL bUpdate = GetUpdateMode() &&
+ ( pCols->GetObject(nItemPos)->IsFrozen() || nItemPos >= nFirstCol );
+
+ if ( bUpdate )
+ {
+ // Selection hiden
+ DoHideCursor( "SetColumnWidth" );
+ ToggleSelection();
+ //!((BrowserDataWin*)pDataWin)->Update();
+ //!Control::Update();
+ }
+
+ // Breite setzen
+ pCols->GetObject(nItemPos)->SetWidth(nWidth, GetZoom());
+#if 0
+ if ( nItemPos != pCols->Count() - 1 )
+ {
+ long nLastColMaxWidth = pDataWin->GetSizePixel().Width() -
+ GetFieldRect(GetColumnId(pCols->Count()-1)).Left();
+ pCols->GetObject(pCols->Count()-1)->Width() = nLastColMaxWidth;
+ }
+#endif
+
+ // scroll and invalidate
+ if ( bUpdate )
+ {
+ // X-Pos der veraenderten Spalte ermitteln
+ long nX = 0;
+ for ( USHORT nCol = 0; nCol < nItemPos; ++nCol )
+ {
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+ if ( pCol->IsFrozen() || nCol >= nFirstCol )
+ nX += pCol->Width();
+ }
+
+ // eigentliches scroll+invalidate
+ pDataWin->SetClipRegion();
+ BOOL bSelVis = bSelectionIsVisible;
+ bSelectionIsVisible = FALSE;
+ if( GetBackground().IsScrollable() )
+ {
+
+ Rectangle aScrRect( nX + min( (ULONG)nOldWidth, nWidth ), 0,
+ GetSizePixel().Width() , // the header is longer than the datawin
+ pDataWin->GetPosPixel().Y() - 1 );
+ Control::Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
+ aScrRect.Bottom() = pDataWin->GetSizePixel().Height();
+ ((BrowserDataWin*)pDataWin)->Scroll( nWidth-nOldWidth, 0, aScrRect, SCROLL_FLAGS );
+ Rectangle aInvRect( nX, 0, nX + max( nWidth, (ULONG)nOldWidth ), USHRT_MAX );
+ Control::Invalidate( aInvRect );
+ ( (BrowserDataWin*)pDataWin )->Invalidate( aInvRect );
+ }
+ else
+ {
+ Control::Invalidate( INVALIDATE_NOCHILDREN );
+ ((BrowserDataWin*)pDataWin)->Window::Invalidate( INVALIDATE_NOCHILDREN );
+ }
+
+
+ //!((BrowserDataWin*)pDataWin)->Update();
+ //!Control::Update();
+ bSelectionIsVisible = bSelVis;
+ ToggleSelection();
+ DoShowCursor( "SetColumnWidth" );
+ }
+ UpdateScrollbars();
+
+ // Headerbar-Column anpassen
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetItemSize(
+ nItemId ? nItemId : USHRT_MAX - 1, nWidth );
+
+ // adjust last column
+ if ( nItemPos != pCols->Count() - 1 )
+ AutoSizeLastColumn();
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::AutoSizeLastColumn()
+{
+ if ( ((BrowserDataWin*)pDataWin)->bAutoSizeLastCol &&
+ ((BrowserDataWin*)pDataWin)->GetUpdateMode() )
+ {
+ USHORT nId = GetColumnId( (USHORT)pCols->Count() - 1 );
+ SetColumnWidth( nId, LONG_MAX );
+ ColumnResized( nId );
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::RemoveColumn( USHORT nItemId )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // Spaltenposition ermitteln
+ USHORT nPos = GetColumnPos(nItemId);
+ if ( nPos >= ColCount() )
+ // nicht vorhanden
+ return;
+
+ // Spaltenselektion korrigieren
+ if ( pColSel )
+ pColSel->Remove( nPos );
+
+ // Spaltencursor korrigieren
+ if ( nCurColId == nItemId )
+ nCurColId = 0;
+
+ if ( nFirstCol >= nPos && nFirstCol > 0 )
+ --nFirstCol;
+
+ // Spalte entfernen
+ delete( pCols->Remove( (ULONG) nPos ));
+
+ // Handlecolumn nicht in der Headerbar
+ if (nItemId)
+ {
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->RemoveItem( nItemId );
+ }
+ else
+ {
+ // Headerbar anpassen
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetPosPixel(
+ Point(0, 0));
+
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetSizePixel(
+ Size( GetOutputSizePixel().Width(), GetTitleHeight() ) );
+ }
+ }
+
+ // vertikalen Scrollbar korrigieren
+ UpdateScrollbars();
+
+ // ggf. Repaint ausl"osen
+ if ( GetUpdateMode() )
+ {
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+ Control::Invalidate();
+ if ( ((BrowserDataWin*)pDataWin)->bAutoSizeLastCol && nPos ==ColCount() )
+ SetColumnWidth( GetColumnId( nPos - 1 ), LONG_MAX );
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::RemoveColumns()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // alle Spalten entfernen
+ while ( pCols->Count() )
+ delete ( pCols->Remove( (ULONG) 0 ));
+
+ // Spaltenselektion korrigieren
+ if ( pColSel )
+ {
+ pColSel->SelectAll(FALSE);
+ pColSel->SetTotalRange( Range( 0, 0 ) );
+ }
+
+ // Spaltencursor korrigieren
+ nCurColId = 0;
+ nFirstCol = 0;
+
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->Clear( );
+
+ // vertikalen Scrollbar korrigieren
+ UpdateScrollbars();
+
+ // ggf. Repaint ausl"osen
+ if ( GetUpdateMode() )
+ {
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+ Control::Invalidate();
+ }
+}
+
+//-------------------------------------------------------------------
+
+String BrowseBox::GetColumnTitle( USHORT nId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ USHORT nItemPos = GetColumnPos( nId );
+ if ( nItemPos >= pCols->Count() )
+ return String();
+ return pCols->GetObject(nItemPos)->Title();
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::GetRowCount() const
+{
+ return nRowCount;
+}
+
+//-------------------------------------------------------------------
+
+USHORT BrowseBox::ColCount() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return (USHORT) pCols->Count();
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::ImpGetDataRowHeight() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ BrowseBox *pThis = (BrowseBox*)this;
+ pThis->nDataRowHeight = pThis->CalcReverseZoom(pDataWin->GetTextHeight() + 2);
+ pThis->Resize();
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+ return nDataRowHeight;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetDataRowHeight( long nPixel )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ nDataRowHeight = CalcReverseZoom(nPixel);
+ Resize();
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetTitleLines( USHORT nLines )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ nTitleLines = nLines;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ToTop()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ToBottom()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::ScrollColumns( long nCols )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( nFirstCol + nCols < 0 ||
+ nFirstCol + nCols >= (long)pCols->Count() )
+ //?MI: pCols->GetObject( nFirstCol + nCols )->IsFrozen() )
+ return 0;
+
+ // implicitly hides cursor while scrolling
+ StartScroll();
+ bScrolling = TRUE;
+ BOOL bScrollable = pDataWin->GetBackground().IsScrollable();
+ BOOL bInvalidateView = FALSE;
+
+ // eine Spalte nach links scrollen?
+ if ( nCols == 1 )
+ {
+ // update internal value and scrollbar
+ ++nFirstCol;
+ aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
+
+ long nDelta = pCols->GetObject(nFirstCol-1)->Width();
+ long nFrozenWidth = GetFrozenWidth();
+
+ // scroll the title-line
+ Rectangle aScrollRect(
+ Point( nFrozenWidth + nDelta, 0 ),
+ Size( GetOutputSizePixel().Width() - nFrozenWidth - nDelta,
+ GetTitleHeight() - 1 ) );
+
+ // ggf. Headerbar mitscrollen
+ if ( !((BrowserDataWin*)pDataWin)->pHeaderBar && nTitleLines )
+ {
+ if( bScrollable )
+ Scroll( -nDelta, 0, aScrollRect );
+ else
+ bInvalidateView = TRUE;
+ }
+
+
+ long nSkippedWidth = GetOutputSizePixel().Width() -
+ 2 * aScrollRect.GetWidth() - nFrozenWidth;
+ if ( nSkippedWidth > 0 )
+ {
+ aScrollRect.Right() = aScrollRect.Left()-1;
+ aScrollRect.Left() -= nSkippedWidth;
+ Invalidate( aScrollRect );
+ }
+
+ // scroll the data-area
+ aScrollRect = Rectangle(
+ Point( nFrozenWidth + nDelta, 0 ),
+ Size( pDataWin->GetOutputSizePixel().Width() - nFrozenWidth -
+ nDelta, pDataWin->GetSizePixel().Height() ) );
+ if( bScrollable )
+ pDataWin->Scroll( -nDelta, 0, aScrollRect );
+ else
+ bInvalidateView = TRUE;
+ nSkippedWidth = pDataWin->GetOutputSizePixel().Width() -
+ 2 * aScrollRect.GetWidth() - nFrozenWidth;
+ if ( nSkippedWidth > 0 )
+ {
+ aScrollRect.Right() = aScrollRect.Left()-1;
+ aScrollRect.Left() -= nSkippedWidth;
+ ((BrowserDataWin*)pDataWin)->Invalidate( aScrollRect );
+ }
+ }
+
+ // eine Spalte nach rechts scrollen?
+ else if ( nCols == -1 )
+ {
+ --nFirstCol;
+ aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
+
+ long nDelta = pCols->GetObject(nFirstCol)->Width();
+ long nFrozenWidth = GetFrozenWidth();
+
+ // ggf. Headerbar mitscrollen
+ if ( !((BrowserDataWin*)pDataWin)->pHeaderBar && nTitleLines )
+ {
+ if( bScrollable )
+ {
+ Scroll( nDelta, 0, Rectangle(
+ Point( nFrozenWidth, 0 ),
+ Size( GetOutputSizePixel().Width() - nFrozenWidth,
+ GetTitleHeight() - 1 ) ) );
+ }
+ else
+ bInvalidateView = TRUE;
+ }
+ if( bScrollable )
+ {
+ pDataWin->Scroll( nDelta, 0, Rectangle(
+ Point( nFrozenWidth, 0 ),
+ Size( pDataWin->GetSizePixel().Width() - nFrozenWidth,
+ pDataWin->GetSizePixel().Height() ) ) );
+ }
+ else
+ bInvalidateView = TRUE;
+
+ }
+ else
+ {
+ if ( GetUpdateMode() )
+ {
+ Invalidate( Rectangle(
+ Point( GetFrozenWidth(), 0 ),
+ Size( GetOutputSizePixel().Width(), GetTitleHeight() ) ) );
+ ((BrowserDataWin*)pDataWin)->Invalidate( Rectangle(
+ Point( GetFrozenWidth(), 0 ),
+ pDataWin->GetSizePixel() ) );
+ }
+
+ nFirstCol += (USHORT)nCols;
+ aHScroll.SetThumbPos( nFirstCol - FrozenColCount() );
+ }
+
+ // ggf. externe Headerbar anpassen
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ long nWidth = 0;
+ for ( USHORT nCol = 0;
+ nCol < pCols->Count() && nCol < nFirstCol;
+ ++nCol )
+ {
+ // HandleColumn nicht
+ if ( pCols->GetObject(nCol)->GetId() )
+ nWidth += pCols->GetObject(nCol)->Width();
+ }
+
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetOffset( nWidth );
+ }
+
+ if( bInvalidateView )
+ {
+ Control::Invalidate( INVALIDATE_NOCHILDREN );
+ pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
+ }
+
+ // implicitly show cursor after scrolling
+ if ( nCols )
+ {
+ ((BrowserDataWin*)pDataWin)->Update();
+ Update();
+ }
+ bScrolling = FALSE;
+ EndScroll();
+
+ return nCols;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::ScrollRows( long nRows )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // out of range?
+ if ( ((BrowserDataWin*)pDataWin)->bNoScrollBack && nRows < 0 )
+ return 0;
+
+ // compute new top row
+ long nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
+
+ long nNewTopRow = Max( (long)nTmpMin, (long)0 );
+
+ if ( nNewTopRow == nTopRow )
+ return 0;
+
+ USHORT nVisibleRows =
+ (USHORT)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
+
+ VisibleRowsChanged(nNewTopRow, nVisibleRows);
+
+ // compute new top row again (nTopRow might have changed!)
+ nTmpMin = Min( (long)(nTopRow + nRows), (long)(nRowCount - 1) );
+
+ nNewTopRow = Max( (long)nTmpMin, (long)0 );
+
+ StartScroll();
+
+ // scroll area on screen and/or repaint
+ long nDeltaY = GetDataRowHeight() * ( nNewTopRow - nTopRow );
+ long nOldTopRow = nTopRow;
+ nTopRow = nNewTopRow;
+
+ if ( GetUpdateMode() )
+ {
+ pVScroll->SetRange( Range( 0L, nRowCount ) );
+ pVScroll->SetThumbPos( nTopRow );
+
+ if( pDataWin->GetBackground().IsScrollable() &&
+ Abs( nDeltaY ) > 0 &&
+ Abs( nDeltaY ) < pDataWin->GetSizePixel().Height() )
+ {
+ pDataWin->Scroll( 0, (short)-nDeltaY );
+ }
+ else
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+
+ if ( nTopRow - nOldTopRow )
+ ((BrowserDataWin*)pDataWin)->Update();
+ }
+
+ EndScroll();
+
+ return nTopRow - nOldTopRow;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::ScrollPages( long nPagesY )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return ScrollRows( pDataWin->GetSizePixel().Height() / GetDataRowHeight() );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::RowModified( long nRow, USHORT nColId )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( !GetUpdateMode() )
+ return;
+
+ Rectangle aRect;
+ if ( nColId == USHRT_MAX )
+ // invalidate the whole row
+ aRect = Rectangle( Point( 0, (nRow-nTopRow) * GetDataRowHeight() ),
+ Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
+ else
+ {
+ // invalidate the specific field
+ aRect = GetFieldRectPixel( nRow, nColId, FALSE );
+ }
+ ((BrowserDataWin*)pDataWin)->Invalidate( aRect );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::Clear()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // adjust the total number of rows
+ DoHideCursor( "Clear" );
+ nRowCount = 0;
+ nCurRow = BROWSER_ENDOFSELECTION;
+ nTopRow = 0;
+ nCurColId = 0;
+
+ // nFirstCol darf nicht zurueckgesetzt werden, da ansonsten das Scrollen
+ // total durcheinander kommt
+ // nFirstCol darf nur beim Hinzufuegen oder Loeschen von Spalten geaendert werden
+ // nFirstCol = 0; ->Falsch!!!!
+ aHScroll.SetThumbPos( 0 );
+ pVScroll->SetThumbPos( 0 );
+
+ Invalidate();
+ UpdateScrollbars();
+ SetNoSelection();
+ DoShowCursor( "Clear" );
+ CursorMoved();
+}
+
+//-------------------------------------------------------------------
+#if SUPD > 511
+
+#else
+
+void BrowseBox::RowInserted( long nRow, long nNumRows, BOOL bDoPaint )
+{
+ RowInserted( nRow, nNumRows, bDoPaint, FALSE );
+}
+
+#endif
+
+void BrowseBox::RowInserted( long nRow, long nNumRows, BOOL bDoPaint, BOOL bKeepSelection )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if (nRow < 0)
+ nRow = 0;
+ else if (nRow > nRowCount) // maximal = nRowCount
+ nRow = nRowCount;
+
+ if ( nNumRows <= 0 )
+ return;
+
+#if 0
+ // Zerlegung in einzelne RowInserted-Aufrufe:
+ if (nNumRows > 1)
+ {
+ for (long i = 0; i < nNumRows; i++)
+ RowInserted(nRow + i,1,bDoPaint);
+ return;
+ }
+#endif
+
+ // adjust total row count
+ BOOL bLastRow = nRow >= nRowCount;
+ nRowCount += nNumRows;
+
+ DoHideCursor( "RowInserted" );
+
+ // must we paint the new rows?
+ long nOldCurRow = nCurRow;
+ Size aSz = pDataWin->GetOutputSizePixel();
+ if ( bDoPaint && nRow >= nTopRow &&
+ nRow <= nTopRow + aSz.Height() / GetDataRowHeight() )
+ {
+ long nY = (nRow-nTopRow) * GetDataRowHeight();
+ if ( !bLastRow )
+ {
+ // scroll down the rows behind the new row
+ pDataWin->SetClipRegion();
+ if( pDataWin->GetBackground().IsScrollable() )
+ {
+ pDataWin->Scroll( 0, GetDataRowHeight() * nNumRows,
+ Rectangle( Point( 0, nY ),
+ Size( aSz.Width(), aSz.Height() - nY ) ),
+ SCROLL_CLIP );
+ }
+ else
+ pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
+ }
+ else
+ // scroll would cause a repaint, so we must explicitly invalidate
+ pDataWin->Invalidate( Rectangle( Point( 0, nY ),
+ Size( aSz.Width(), nNumRows * GetDataRowHeight() ) ) );
+ }
+
+ // ggf. Top-Row korrigieren
+ if ( nRow < nTopRow )
+ nTopRow += nNumRows;
+
+ // adjust the selection
+ if ( bMultiSelection )
+ uRow.pSel->Insert( nRow, nNumRows );
+ else if ( uRow.nSel != BROWSER_ENDOFSELECTION && nRow <= uRow.nSel )
+ uRow.nSel += nNumRows;
+
+ // adjust the cursor
+ if ( nCurRow == BROWSER_ENDOFSELECTION )
+ GoToRow( 0, FALSE, bKeepSelection );
+ else if ( nRow <= nCurRow )
+ GoToRow( nCurRow += nNumRows, FALSE, bKeepSelection );
+
+ // adjust the vertical scrollbar
+ if ( bDoPaint )
+ {
+ UpdateScrollbars();
+ AutoSizeLastColumn();
+ }
+
+ DoShowCursor( "RowInserted" );
+ if ( nCurRow != nOldCurRow )
+ CursorMoved();
+
+ DBG_ASSERT(nRowCount > 0,"BrowseBox: nRowCount <= 0");
+ DBG_ASSERT(nCurRow >= 0,"BrowseBox: nCurRow < 0");
+ DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount");
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::RowRemoved( long nRow, long nNumRows, BOOL bDoPaint )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( nRow < 0 )
+ nRow = 0;
+ else if ( nRow >= nRowCount )
+ nRow = nRowCount - 1;
+
+ if ( nNumRows <= 0 )
+ return;
+
+ if ( nRowCount <= 0 )
+ return;
+
+ if ( bDoPaint )
+ {
+ // hide cursor and selection
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+ ToggleSelection();
+ DoHideCursor( "RowRemoved" );
+ }
+
+ // adjust total row count
+ nRowCount -= nNumRows;
+ if (nRowCount < 0) nRowCount = 0;
+ long nOldCurRow = nCurRow;
+
+ // adjust the selection
+ if ( bMultiSelection )
+ // uRow.pSel->Remove( nRow, nNumRows );
+ for ( long i = 0; i < nNumRows; i++ )
+ uRow.pSel->Remove( nRow );
+ else if ( nRow < uRow.nSel && uRow.nSel >= nNumRows )
+ uRow.nSel -= nNumRows;
+ else if ( nRow <= uRow.nSel )
+ uRow.nSel = BROWSER_ENDOFSELECTION;
+
+ // adjust the cursor
+ if ( nRowCount == 0 ) // don't compare nRowCount with nNumRows as nNumRows already was subtracted from nRowCount
+ nCurRow = BROWSER_ENDOFSELECTION;
+ else if ( nRow < nCurRow )
+ {
+ nCurRow -= Min( nCurRow - nRow, nNumRows );
+ // with the above nCurRow points a) to the first row after the removed block or b) to the same line
+ // as before, but moved up nNumRows
+ // case a) needs an additional correction if the last n lines were deleted, as 'the first row after the
+ // removed block' is an invalid position then
+ // FS - 09/28/99 - 68429
+ if (nCurRow == nRowCount)
+ --nCurRow;
+ }
+ else if( nRow == nCurRow && nCurRow == nRowCount )
+ nCurRow = nRowCount-1;
+
+ // is the deleted row visible?
+ Size aSz = pDataWin->GetOutputSizePixel();
+ if ( nRow >= nTopRow &&
+ nRow <= nTopRow + aSz.Height() / GetDataRowHeight() )
+ {
+ if ( bDoPaint )
+ {
+ // scroll up the rows behind the deleted row
+ // if there are Rows behind
+ if (nRow < nRowCount)
+ {
+ long nY = (nRow-nTopRow) * GetDataRowHeight();
+ pDataWin->SetClipRegion();
+ if( pDataWin->GetBackground().IsScrollable() )
+ {
+ pDataWin->Scroll( 0, - (short) GetDataRowHeight() * nNumRows,
+ Rectangle( Point( 0, nY ), Size( aSz.Width(),
+ aSz.Height() - nY + nNumRows*GetDataRowHeight() ) ),
+ SCROLL_CLIP );
+ }
+ else
+ pDataWin->Window::Invalidate( INVALIDATE_NOCHILDREN );
+ }
+ else
+ {
+ // Repaint the Rect of the deleted row
+ Rectangle aRect(
+ Point( 0, (nRow-nTopRow)*GetDataRowHeight() ),
+ Size( pDataWin->GetSizePixel().Width(),
+ nNumRows * GetDataRowHeight() ) );
+ pDataWin->Invalidate( aRect );
+ }
+ }
+ }
+ // is the deleted row above of the visible area?
+ else if ( nRow < nTopRow )
+ nTopRow = nTopRow >= nNumRows ? nTopRow-nNumRows : 0;
+
+ if ( bDoPaint )
+ {
+ // reshow cursor and selection
+ ToggleSelection();
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+ DoShowCursor( "RowRemoved" );
+
+ // adjust the vertical scrollbar
+ UpdateScrollbars();
+ AutoSizeLastColumn();
+ }
+
+ if ( nOldCurRow != nCurRow )
+ CursorMoved();
+
+ DBG_ASSERT(nRowCount >= 0,"BrowseBox: nRowCount < 0");
+ DBG_ASSERT(nCurRow >= 0 || nRowCount == 0,"BrowseBox: nCurRow < 0 && nRowCount != 0");
+ DBG_ASSERT(nCurRow < nRowCount,"nCurRow >= nRowCount");
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::GoToRow( long nRow)
+{
+ return GoToRow(nRow, FALSE, FALSE);
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::GoToRowAndDoNotModifySelection( long nRow )
+{
+ return GoToRow( nRow, FALSE, TRUE );
+}
+
+//-------------------------------------------------------------------
+
+#if SUPD > 511
+
+#else
+BOOL BrowseBox::GoToRow( long nRow, BOOL bRowColMove )
+{
+ return GoToRow( nRow, bRowColMove, FALSE );
+}
+#endif
+
+BOOL BrowseBox::GoToRow( long nRow, BOOL bRowColMove, BOOL bKeepSelection )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ long nOldCurRow = nCurRow;
+
+ // nothing to do?
+ if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) )
+ return TRUE;
+
+ // out of range?
+ if ( nRow < 0 || nRow >= nRowCount )
+ return FALSE;
+
+ // nicht erlaubt?
+ if ( ( !bRowColMove && !IsCursorMoveAllowed( nRow, nCurColId ) ) )
+ return FALSE;
+
+ if ( ((BrowserDataWin*)pDataWin)->bNoScrollBack && nRow < nTopRow )
+ nRow = nTopRow;
+
+ // compute the last visible row
+ Size aSz( pDataWin->GetSizePixel() );
+ USHORT nVisibleRows = USHORT( aSz.Height() ) / GetDataRowHeight() - 1;
+ long nLastRow = nTopRow + nVisibleRows;
+
+ // suspend Updates
+ ((BrowserDataWin*)pDataWin)->EnterUpdateLock();
+
+ // ggf. altes Highlight weg
+ if ( !bMultiSelection && !bKeepSelection )
+ ToggleSelection();
+ DoHideCursor( "GoToRow" );
+
+ // must we scroll?
+ BOOL bWasVisible = bSelectionIsVisible;
+ if (! bMultiSelection)
+ {
+ if( !bKeepSelection )
+ bSelectionIsVisible = FALSE;
+ }
+ if ( nRow < nTopRow )
+ ScrollRows( nRow - nTopRow );
+ else if ( nRow > nLastRow )
+ ScrollRows( nRow - nLastRow );
+ bSelectionIsVisible = bWasVisible;
+
+ // adjust cursor (selection) and thumb
+ if ( GetUpdateMode() )
+ pVScroll->SetThumbPos( nTopRow );
+
+ // relative positioning (because nCurRow might have changed in the meantime)!
+ if (nCurRow != BROWSER_ENDOFSELECTION )
+ nCurRow = nCurRow + (nRow - nOldCurRow);
+
+ // make sure that the current position is valid
+ if (nCurRow == BROWSER_ENDOFSELECTION && nRowCount > 0)
+ nCurRow = 0;
+ else if ( nCurRow >= nRowCount )
+ nCurRow = nRowCount - 1;
+ aSelRange = Range( nCurRow, nCurRow );
+
+ // ggf. neues Highlight anzeigen
+ if ( !bMultiSelection && !bKeepSelection )
+ uRow.nSel = nRow;
+
+ // resume Updates
+ ((BrowserDataWin*)pDataWin)->LeaveUpdateLock();
+
+ // Cursor+Highlight
+ if ( !bMultiSelection && !bKeepSelection)
+ ToggleSelection();
+ DoShowCursor( "GoToRow" );
+ if ( !bRowColMove && nOldCurRow != nCurRow )
+ CursorMoved();
+
+ if ( !bMultiSelection && !bKeepSelection )
+ if ( !bSelecting )
+ Select();
+ else
+ bSelect = TRUE;
+ return TRUE;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::GoToColumnId( USHORT nColId)
+{
+ return GoToColumnId(nColId,TRUE,FALSE);
+}
+
+
+BOOL BrowseBox::GoToColumnId( USHORT nColId, BOOL bMakeVisible, BOOL bRowColMove)
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if (!bColumnCursor)
+ return FALSE;
+
+ // erlaubt?
+ if (!bRowColMove && !IsCursorMoveAllowed( nCurRow, nColId ) )
+ return FALSE;
+
+ if ( nColId != nCurColId || bMakeVisible && !IsFieldVisible(nCurRow, nColId, TRUE))
+ {
+ DoHideCursor( "GoToColumnId" );
+ nCurColId = nColId;
+
+ USHORT nNewPos = GetColumnPos(nColId);
+ DBG_ASSERT( nNewPos != USHRT_MAX, "unknown column-id" );
+ USHORT nFirstPos = nFirstCol;
+ USHORT nWidth = (USHORT)pCols->GetObject( nNewPos )->Width();
+ USHORT nLastPos = GetColumnAtXPosPixel(
+ pDataWin->GetSizePixel().Width()-nWidth, FALSE );
+ USHORT nFrozen = FrozenColCount();
+ if ( bMakeVisible && nLastPos &&
+ nNewPos >= nFrozen && ( nNewPos < nFirstPos || nNewPos > nLastPos ) )
+ if ( nNewPos < nFirstPos )
+ ScrollColumns( nNewPos-nFirstPos );
+ else if ( nNewPos > nLastPos )
+ ScrollColumns( nNewPos-nLastPos );
+
+ DoShowCursor( "GoToColumnId" );
+ if (!bRowColMove)
+ CursorMoved();
+ return TRUE;
+ }
+ return TRUE;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::GoToRowColumnId( long nRow, USHORT nColId )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ long nOldCurRow = nCurRow;
+
+ // out of range?
+ if ( nRow < 0 || nRow >= nRowCount )
+ return FALSE;
+
+ if (!bColumnCursor)
+ return FALSE;
+
+ // nothing to do ?
+ if ( nRow == nCurRow && ( bMultiSelection || uRow.nSel == nRow ) &&
+ nColId == nCurColId && IsFieldVisible(nCurRow, nColId, TRUE))
+ return TRUE;
+
+ // erlaubt?
+ if (!IsCursorMoveAllowed(nRow, nColId))
+ return FALSE;
+
+ DoHideCursor( "GoToRowColumnId" );
+ BOOL bMoved = GoToRow(nRow, TRUE) && GoToColumnId(nColId, TRUE, TRUE);
+ DoShowCursor( "GoToRowColumnId" );
+
+ if (bMoved)
+ CursorMoved();
+
+ return bMoved;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetNoSelection()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // is there no selection
+ if ( ( !pColSel || !pColSel->GetSelectCount() ) &&
+ ( ( !bMultiSelection && uRow.nSel == BROWSER_ENDOFSELECTION ) ||
+ ( bMultiSelection && !uRow.pSel->GetSelectCount() ) ) )
+ // nothing to do
+ return;
+
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+ ToggleSelection();
+
+ // unselect all
+ if ( bMultiSelection )
+ uRow.pSel->SelectAll(FALSE);
+ else
+ uRow.nSel = BROWSER_ENDOFSELECTION;
+ if ( pColSel )
+ pColSel->SelectAll(FALSE);
+ if ( !bSelecting )
+ Select();
+ else
+ bSelect = TRUE;
+
+ // restore screen
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetSelection( const MultiSelection &rSel )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ DBG_ASSERT( bMultiSelection, "SetSelection only allowed with Multi-Selection-Mode" );
+
+ // prepare inverted areas
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+ ToggleSelection();
+
+ // assign Selection
+ *uRow.pSel = rSel;
+
+ // only highlight painted areas
+ pDataWin->Update();
+
+ // notify derived class
+ if ( !bSelecting )
+ Select();
+ else
+ bSelect = TRUE;
+
+ // restore screen
+ ToggleSelection();
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SelectAll()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( !bMultiSelection )
+ return;
+
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+ ToggleSelection();
+
+ // select all rows
+ if ( pColSel )
+ pColSel->SelectAll(FALSE);
+ uRow.pSel->SelectAll(TRUE);
+
+ // Handle-Column nicht highlighten
+ BrowserColumn *pFirstCol = pCols->GetObject(0);
+ long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
+
+ // highlight the row selection
+ if ( !bHideSelect )
+ {
+ Rectangle aHighlightRect;
+ USHORT nVisibleRows =
+ (USHORT)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
+ for ( long nRow = Max( nTopRow, uRow.pSel->FirstSelected() );
+ nRow != BROWSER_ENDOFSELECTION && nRow < nTopRow + nVisibleRows;
+ nRow = uRow.pSel->NextSelected() )
+ aHighlightRect.Union( Rectangle(
+ Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
+ Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) ) );
+ pDataWin->Invalidate( aHighlightRect );
+ }
+
+ if ( !bSelecting )
+ Select();
+ else
+ bSelect = TRUE;
+
+ // restore screen
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SelectRow( long nRow, BOOL bSelect, BOOL bExpand )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( !bMultiSelection )
+ {
+ // deselecting is impossible, selecting via cursor
+ if ( bSelect )
+ GoToRow(nRow, FALSE);
+ return;
+ }
+
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+
+ // remove old selection?
+ if ( !bExpand || !bMultiSelection )
+ {
+ ToggleSelection();
+ if ( bMultiSelection )
+ uRow.pSel->SelectAll(FALSE);
+ else
+ uRow.nSel = BROWSER_ENDOFSELECTION;
+ if ( pColSel )
+ pColSel->SelectAll(FALSE);
+ }
+
+ // set new selection
+ if ( !bHideSelect &&
+ ( (bMultiSelection && uRow.pSel->GetTotalRange().Max() >= nRow && uRow.pSel->Select(nRow,bSelect)) ||
+ (!bMultiSelection && ( uRow.nSel = nRow ) != BROWSER_ENDOFSELECTION ) ) )
+ {
+ // Handle-Column nicht highlighten
+ BrowserColumn *pFirstCol = pCols->GetObject(0);
+ long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
+
+ // highlight only newly selected part
+ Rectangle aRect(
+ Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
+ Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
+ pDataWin->Invalidate( aRect );
+ }
+
+ if ( !bSelecting )
+ Select();
+ else
+ bSelect = TRUE;
+
+ // restore screen
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::GetSelectRowCount() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return bMultiSelection ? uRow.pSel->GetSelectCount() :
+ uRow.nSel == BROWSER_ENDOFSELECTION ? 0 : 1;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SelectColumnPos( USHORT nNewColPos, BOOL bSelect, BOOL bMakeVisible )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( !bColumnCursor )
+ return;
+
+ if ( !bMultiSelection )
+ {
+ if ( bSelect )
+ GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible );
+ return;
+ }
+ else if (!GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible ))
+ return;
+
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+ ToggleSelection();
+ if ( bMultiSelection )
+ uRow.pSel->SelectAll(FALSE);
+ else
+ uRow.nSel = BROWSER_ENDOFSELECTION;
+ pColSel->SelectAll(FALSE);
+
+ if ( pColSel->Select( nNewColPos ) )
+ {
+ // GoToColumnId( pCols->GetObject(nNewColPos)->GetId(), bMakeVisible );
+
+ // only highlight painted areas
+ pDataWin->Update();
+ Rectangle aFieldRectPix( GetFieldRectPixel( nCurRow, nCurColId, FALSE ) );
+ Rectangle aRect(
+ Point( aFieldRectPix.Left() - MIN_COLUMNWIDTH, 0 ),
+ Size( pCols->GetObject(nNewColPos)->Width(),
+ pDataWin->GetOutputSizePixel().Height() ) );
+ pDataWin->Invalidate( aRect );
+ if ( !bSelecting )
+ Select();
+ else
+ bSelect = TRUE;
+ }
+
+ // restore screen
+ DBG_TRACE1( "BrowseBox: %p->ShowCursor", this );
+}
+
+//-------------------------------------------------------------------
+
+USHORT BrowseBox::GetSelectColumnCount() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // while bAutoSelect (==!pColSel), 1 if any rows (yes rows!) else none
+ return pColSel ? (USHORT) pColSel->GetSelectCount() :
+ nCurRow >= 0 ? 1 : 0;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::FirstSelectedRow( BOOL bInverse )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return bMultiSelection ? uRow.pSel->FirstSelected(bInverse) : uRow.nSel;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::NextSelectedRow()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::PrevSelectedRow()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return bMultiSelection ? uRow.pSel->PrevSelected() : BROWSER_ENDOFSELECTION;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::LastSelectedRow( BOOL bInverse )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return bMultiSelection ? uRow.pSel->LastSelected(bInverse) : uRow.nSel;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::IsRowSelected( long nRow ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return bMultiSelection ? uRow.pSel->IsSelected(nRow) : nRow == uRow.nSel;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::IsColumnSelected( USHORT nColumnId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return pColSel ? pColSel->IsSelected( GetColumnPos(nColumnId) ) :
+ nCurColId == nColumnId;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::MakeFieldVisible
+(
+ long nRow, // Zeilen-Nr des Feldes (beginnend mit 0)
+ USHORT nColId, // Spalten-Id des Feldes
+ BOOL bComplete // (== FALSE), TRUE => vollst"andig sichtbar machen
+)
+
+/* [Beschreibung]
+
+ Macht das durch 'nRow' und 'nColId' beschriebene Feld durch
+ entsprechendes scrollen sichtbar. Ist 'bComplete' gesetzt, dann wird
+ gefordert, da\s das Feld ganz sichtbar wird.
+
+ [R"uckgabewert]
+
+ BOOL TRUE
+ Das angegebene Feld wurde sichtbar gemacht, bzw. war
+ bereits sichtbar.
+
+ FALSE
+ Das angegebene Feld konnte nicht sichtbar bzw. bei
+ 'bComplete' nicht vollst"andig sichtbar gemacht werden.
+*/
+
+{
+ Size aTestSize = pDataWin->GetSizePixel();
+
+ if ( !bBootstrapped ||
+ ( aTestSize.Width() == 0 && aTestSize.Height() == 0 ) )
+ return FALSE;
+
+ // ist es schon sichtbar?
+ BOOL bVisible = IsFieldVisible( nRow, nColId, bComplete );
+ if ( bVisible )
+ return TRUE;
+
+ // Spaltenposition und Feld-Rechteck und Ausgabebereich berechnen
+ USHORT nColPos = GetColumnPos( nColId );
+ Rectangle aFieldRect = GetFieldRectPixel( nRow, nColId, FALSE );
+ Rectangle aDataRect = Rectangle( Point(0, 0), pDataWin->GetSizePixel() );
+
+ // links au\serhalb?
+ if ( nColPos >= FrozenColCount() && nColPos < nFirstCol )
+ // => nach rechts scrollen
+ ScrollColumns( nColPos - nFirstCol );
+
+ // solange rechts au\serhalb
+ while ( aDataRect.Right() < ( bComplete
+ ? aFieldRect.Right()
+ : aFieldRect.Left()+aFieldRect.GetWidth()/2 ) )
+ {
+ // => nach links scrollen
+ if ( ScrollColumns( 1 ) != 1 )
+ // nichts mehr zu scrollen
+ break;
+ aFieldRect = GetFieldRectPixel( nRow, nColId, FALSE );
+ }
+
+ // oben au\serhalb?
+ if ( nRow < nTopRow )
+ // nach unten scrollen
+ ScrollRows( nRow - nTopRow );
+
+ // unten au\serhalb?
+ long nBottomRow = nTopRow + GetVisibleRows();
+ // OV: damit nBottomRow die Nummer der letzten sichtbaren Zeile ist
+ // (Zaehlung ab Null!), muss sie dekrementiert werden.
+ // Beispiel: BrowseBox enthaelt genau einen Eintrag. nBottomRow := 0 + 1 - 1
+ if( nBottomRow )
+ nBottomRow--;
+
+ if ( nRow > nBottomRow )
+ // nach oben scrollen
+ ScrollRows( nRow - nBottomRow );
+
+ // jetzt kann es immer noch nicht passen, z.B. weil Window zu klein
+ return IsFieldVisible( nRow, nColId, bComplete );
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::IsFieldVisible( long nRow, USHORT nColumnId,
+ BOOL bCompletely ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // durch frozen-Column verdeckt?
+ USHORT nColPos = GetColumnPos( nColumnId );
+ if ( nColPos >= FrozenColCount() && nColPos < nFirstCol )
+ return FALSE;
+
+ Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) );
+ if ( aRect.IsEmpty() )
+ return FALSE;
+
+ // get the visible area
+ Rectangle aOutRect( Point(0, 0), pDataWin->GetOutputSizePixel() );
+
+ if ( bCompletely )
+ // test if the field is completely visible
+ return aOutRect.IsInside( aRect );
+ else
+ // test if the field is partly of completely visible
+ return !aOutRect.Intersection( aRect ).IsEmpty();
+}
+
+//-------------------------------------------------------------------
+
+Rectangle BrowseBox::GetFieldRectPixel( long nRow, USHORT nColumnId,
+ BOOL bRelToBrowser ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // get the rectangle relative to DataWin
+ Rectangle aRect( ImplFieldRectPixel( nRow, nColumnId ) );
+ if ( aRect.IsEmpty() )
+ return aRect;
+
+ // adjust relative to BrowseBox's output area
+ Point aTopLeft( aRect.TopLeft() );
+ if ( bRelToBrowser )
+ {
+ aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft );
+ aTopLeft = ScreenToOutputPixel( aTopLeft );
+ }
+
+ return Rectangle( aTopLeft, aRect.GetSize() );
+}
+
+//-------------------------------------------------------------------
+
+Rectangle BrowseBox::GetRowRectPixel( long nRow, BOOL bRelToBrowser ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // get the rectangle relative to DataWin
+ Rectangle aRect;
+ if ( nTopRow > nRow )
+ // row is above visible area
+ return aRect;
+ aRect = Rectangle(
+ Point( 0, GetDataRowHeight() * (nRow-nTopRow) ),
+ Size( pDataWin->GetOutputSizePixel().Width(), GetDataRowHeight() ) );
+ if ( aRect.TopLeft().Y() > pDataWin->GetOutputSizePixel().Height() )
+ // row is below visible area
+ return aRect;
+
+ // adjust relative to BrowseBox's output area
+ Point aTopLeft( aRect.TopLeft() );
+ if ( bRelToBrowser )
+ {
+ aTopLeft = pDataWin->OutputToScreenPixel( aTopLeft );
+ aTopLeft = ScreenToOutputPixel( aTopLeft );
+ }
+
+ return Rectangle( aTopLeft, aRect.GetSize() );
+}
+
+//-------------------------------------------------------------------
+
+Rectangle BrowseBox::ImplFieldRectPixel( long nRow, USHORT nColumnId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // compute the X-coordinte realtiv to DataWin by accumulation
+ long nColX = 0;
+ USHORT nFrozenCols = FrozenColCount();
+ USHORT nCol;
+ for ( nCol = 0;
+ nCol < pCols->Count() && pCols->GetObject(nCol)->GetId() != nColumnId;
+ ++nCol )
+ if ( pCols->GetObject(nCol)->IsFrozen() || nCol >= nFirstCol )
+ nColX += pCols->GetObject(nCol)->Width();
+
+ if ( nCol >= pCols->Count() || ( nCol >= nFrozenCols && nCol < nFirstCol ) )
+ return Rectangle();
+
+ // compute the Y-coordinate relative to DataWin
+ long nRowY = ( nRow - nTopRow ) * GetDataRowHeight();
+
+ // assemble the Rectangle relative to DataWin
+ return Rectangle(
+ Point( nColX + MIN_COLUMNWIDTH, nRowY ),
+ Size( pCols->GetObject(nCol)->Width() - 2*MIN_COLUMNWIDTH,
+ GetDataRowHeight() - 1 ) );
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::GetRowAtYPosPixel( long nY, BOOL bRelToBrowser ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // compute the Y-coord
+ if ( bRelToBrowser )
+ {
+ Point aDataTopLeft = pDataWin->OutputToScreenPixel( Point(0, 0) );
+ Point aTopLeft = OutputToScreenPixel( Point(0, 0) );
+ nY -= aDataTopLeft.Y() - aTopLeft.Y();
+ }
+
+ // no row there (e.g. in the header)
+ if ( nY < 0 || nY >= pDataWin->GetOutputSizePixel().Height() )
+ return -1;
+
+ return nY / GetDataRowHeight() + nTopRow;
+}
+
+//-------------------------------------------------------------------
+
+Rectangle BrowseBox::GetFieldRect( USHORT nColumnId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return GetFieldRectPixel( nCurRow, nColumnId );
+}
+
+//-------------------------------------------------------------------
+
+USHORT BrowseBox::GetColumnAtXPosPixel( long nX, BOOL ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // accumulate the withds of the visible columns
+ long nColX = 0;
+ USHORT nCol;
+ for ( nCol = 0; nCol < USHORT(pCols->Count()); ++nCol )
+ {
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+ if ( pCol->IsFrozen() || nCol >= nFirstCol )
+ nColX += pCol->Width();
+
+ if ( nColX > nX )
+ return nCol;
+ }
+
+ return BROWSER_INVALIDID;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ReserveControlArea( USHORT nWidth )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( nWidth != nControlAreaWidth )
+ {
+ nControlAreaWidth = nWidth;
+ UpdateScrollbars();
+ }
+}
+
+//-------------------------------------------------------------------
+
+Rectangle BrowseBox::GetControlArea() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return Rectangle(
+ Point( 0, GetOutputSizePixel().Height() - aHScroll.GetSizePixel().Height() ),
+ Size( GetOutputSizePixel().Width() - aHScroll.GetSizePixel().Width(),
+ aHScroll.GetSizePixel().Height() ) );
+}
+
+#if SUPD<558
+//-------------------------------------------------------------------
+
+BrowserMode BrowseBox::GetMode( ) const
+{
+ return m_nCurrentMode;
+}
+#endif
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetMode( BrowserMode nMode )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+#ifdef DBG_MIx
+ Sound::Beep();
+ nMode =
+// BROWSER_COLUMNSELECTION |
+// BROWSER_MULTISELECTION |
+ BROWSER_THUMBDRAGGING |
+ BROWSER_KEEPHIGHLIGHT |
+ BROWSER_HLINES |
+ BROWSER_VLINES |
+// BROWSER_HIDECURSOR |
+// BROWSER_NO_HSCROLL |
+// BROWSER_NO_SCROLLBACK |
+ BROWSER_AUTO_VSCROLL |
+ BROWSER_AUTO_HSCROLL |
+ BROWSER_TRACKING_TIPS |
+// BROWSER_HIGHLIGHT_NONE |
+ BROWSER_HIGHLIGHT_AUTO |
+// BROWSER_HIGHLIGHT_MANU |
+ BROWSER_HEADERBAR_NEW |
+// BROWSER_AUTOSIZE_LASTCOL |
+ 0;
+#endif
+
+ ((BrowserDataWin*)pDataWin)->bAutoHScroll =
+ BROWSER_AUTO_HSCROLL == ( nMode & BROWSER_AUTO_HSCROLL);
+ ((BrowserDataWin*)pDataWin)->bAutoVScroll =
+ BROWSER_AUTO_VSCROLL == ( nMode & BROWSER_AUTO_VSCROLL);
+
+ ((BrowserDataWin*)pDataWin)->bNoHScroll =
+ BROWSER_NO_HSCROLL == ( nMode & BROWSER_NO_HSCROLL);
+ if ( ((BrowserDataWin*)pDataWin)->bNoHScroll )
+ {
+ aHScroll.Hide();
+ nControlAreaWidth = 0;
+ }
+ else
+ nControlAreaWidth = USHRT_MAX;
+
+ ((BrowserDataWin*)pDataWin)->bNoScrollBack =
+ BROWSER_NO_SCROLLBACK == ( nMode & BROWSER_NO_SCROLLBACK);
+
+ long nOldRowSel = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel;
+ MultiSelection *pOldRowSel = bMultiSelection ? uRow.pSel : 0;
+ MultiSelection *pOldColSel = pColSel;
+
+ delete pVScroll;
+
+ bThumbDragging = ( nMode & BROWSER_THUMBDRAGGING ) == BROWSER_THUMBDRAGGING;
+ bMultiSelection = ( nMode & BROWSER_MULTISELECTION ) == BROWSER_MULTISELECTION;
+ bColumnCursor = ( nMode & BROWSER_COLUMNSELECTION ) == BROWSER_COLUMNSELECTION;
+ bKeepHighlight = ( nMode & BROWSER_KEEPSELECTION ) == BROWSER_KEEPSELECTION;
+
+ bHideSelect = ((nMode & BROWSER_HIDESELECT) == BROWSER_HIDESELECT);
+ bHideCursor = ((nMode & BROWSER_HIDECURSOR) == BROWSER_HIDECURSOR);
+ m_bFocusOnlyCursor = ((nMode & BROWSER_CURSOR_WO_FOCUS) == 0);
+
+ bHLines = ( nMode & BROWSER_HLINESFULL ) == BROWSER_HLINESFULL;
+ bVLines = ( nMode & BROWSER_VLINESFULL ) == BROWSER_VLINESFULL;
+ bHDots = ( nMode & BROWSER_HLINESDOTS ) == BROWSER_HLINESDOTS;
+ bVDots = ( nMode & BROWSER_VLINESDOTS ) == BROWSER_VLINESDOTS;
+
+ WinBits nVScrollWinBits =
+ WB_VSCROLL | ( ( nMode & BROWSER_THUMBDRAGGING ) ? WB_DRAG : 0 );
+ pVScroll = ( nMode & BROWSER_TRACKING_TIPS ) == BROWSER_TRACKING_TIPS
+ ? new BrowserScrollBar( this, nVScrollWinBits,
+ (BrowserDataWin*) pDataWin )
+ : new ScrollBar( this, nVScrollWinBits );
+ pVScroll->SetLineSize( 1 );
+ pVScroll->SetPageSize(1);
+ pVScroll->SetScrollHdl( LINK( this, BrowseBox, ScrollHdl ) );
+ pVScroll->SetEndScrollHdl( LINK( this, BrowseBox, EndScrollHdl ) );
+
+ ((BrowserDataWin*)pDataWin)->bHighlightAuto =
+ BROWSER_HIGHLIGHT_AUTO == ( nMode & BROWSER_HIGHLIGHT_AUTO ) ||
+ BROWSER_HIGHLIGHT_MANU != ( nMode & BROWSER_HIGHLIGHT_MANU );
+ ((BrowserDataWin*)pDataWin)->bAutoSizeLastCol =
+ BROWSER_AUTOSIZE_LASTCOL == ( nMode & BROWSER_AUTOSIZE_LASTCOL );
+ ((BrowserDataWin*)pDataWin)->bOwnDataChangedHdl =
+ BROWSER_OWN_DATACHANGED == ( nMode & BROWSER_OWN_DATACHANGED );
+
+ // Headerbar erzeugen, was passiert, wenn eine erzeugt werden muß und schon Spalten bestehen ?
+ if ( BROWSER_HEADERBAR_NEW == ( nMode & BROWSER_HEADERBAR_NEW ) )
+ {
+ if (!((BrowserDataWin*)pDataWin)->pHeaderBar)
+ ((BrowserDataWin*)pDataWin)->pHeaderBar = CreateHeaderBar( this );
+ }
+ else
+ {
+ DELETEZ(((BrowserDataWin*)pDataWin)->pHeaderBar);
+ }
+
+
+
+ if ( bColumnCursor )
+ {
+ pColSel = pOldColSel ? pOldColSel : new MultiSelection;
+ pColSel->SetTotalRange( Range( 0, pCols->Count()-1 ) );
+ }
+ else
+ {
+ pColSel = 0;
+ delete pColSel;
+ }
+
+ if ( bMultiSelection )
+ {
+ if ( pOldRowSel )
+ uRow.pSel = pOldRowSel;
+ else
+ uRow.pSel = new MultiSelection;
+ }
+ else
+ {
+ uRow.nSel = nOldRowSel;
+ delete pOldRowSel;
+ }
+
+ if ( bBootstrapped )
+ {
+ StateChanged( STATE_CHANGE_INITSHOW );
+ if ( bMultiSelection && !pOldRowSel &&
+ nOldRowSel != BROWSER_ENDOFSELECTION )
+ uRow.pSel->Select( nOldRowSel );
+ }
+
+ if ( pDataWin )
+ pDataWin->Invalidate();
+
+ // kein Cursor auf Handle-Column
+ if ( nCurColId == 0 )
+ nCurColId = GetColumnId( 1 );
+
+ m_nCurrentMode = nMode;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::VisibleRowsChanged( long nNewTopRow, USHORT nNumRows)
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // Das alte Verhalten: NumRows automatisch korrigieren:
+ if ( nRowCount < GetRowCount() )
+ {
+ RowInserted(nRowCount,GetRowCount() - nRowCount,FALSE);
+ }
+ else if ( nRowCount > GetRowCount() )
+ {
+ RowRemoved(nRowCount-(nRowCount - GetRowCount()),nRowCount - GetRowCount(),FALSE);
+ }
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::IsCursorMoveAllowed( long nNewRow, USHORT nNewColId ) const
+
+/* [Beschreibung]
+
+ Diese virtuelle Methode wird immer gerufen bevor der Cursor direkt
+ bewegt werden soll. Durch 'return FALSE' kann verhindert werden, da\s
+ dies geschieht, wenn z.B. ein Datensatz irgendwelchen Rules widerspricht.
+
+ Diese Methode wird nicht gerufen, wenn die Cursorbewegung durch
+ ein L"oschen oder Einf"ugen (einer Zeile/Spalte) ausgel"ost wird, also
+ genaugenommen nur eine Cursor-Korrektur vorliegt.
+
+ Die Basisimplementierung liefert derzeit immer TRUE.
+*/
+
+{
+ return TRUE;
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::GetDataRowHeight() const
+{
+ return CalcZoom(nDataRowHeight ? nDataRowHeight : ImpGetDataRowHeight());
+}
+
+//-------------------------------------------------------------------
+
+Window& BrowseBox::GetEventWindow() const
+{
+ return *((BrowserDataWin*)pDataWin)->pEventWin;
+}
+
+//-------------------------------------------------------------------
+
+#if SUPD >= 376
+
+BrowserHeader* BrowseBox::CreateHeaderBar( BrowseBox* pParent )
+{
+ BrowserHeader* pNewBar = new BrowserHeader( pParent );
+ pNewBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) );
+ return pNewBar;
+}
+
+void BrowseBox::SetHeaderBar( BrowserHeader* pHeaderBar )
+{
+ delete ( (BrowserDataWin*)pDataWin )->pHeaderBar;
+ ( (BrowserDataWin*)pDataWin )->pHeaderBar = pHeaderBar;
+ ( (BrowserDataWin*)pDataWin )->pHeaderBar->SetStartDragHdl( LINK( this, BrowseBox, StartDragHdl ) );
+}
+
+#endif
+
+//-------------------------------------------------------------------
+
+#ifdef DBG_UTIL
+const char* BrowseBoxCheckInvariants( const void * pVoid )
+{
+ const BrowseBox * p = (const BrowseBox *)pVoid;
+
+ if (p->nRowCount < 0) return "BrowseBox: nRowCount < 0";
+ if (p->nTopRow < 0) return "BrowseBox: nTopRow < 0";
+ if (p->nTopRow >= p->nRowCount && p->nRowCount != 0) return "BrowseBox: nTopRow >= nRowCount && nRowCount != 0";
+ if (p->nCurRow < -1) return "BrowseBox: nCurRow < -1";
+ if (p->nCurRow > p->nRowCount) return "BrowseBox: nCurRow > nRowCount";
+
+ // Leider waehrend der Bearbeitung nicht immer der Fall:
+ //if (p->nCurRow < 0 && p->nRowCount != 0) return "nCurRow < 0 && nRowCount != 0";
+ //if (p->nCurRow >= p->nRowCount && p->nRowCount != 0) return "nCurRow >= nRowCount && nRowCount != 0";
+
+ return NULL;
+}
+#endif
+
+//-------------------------------------------------------------------
+long BrowseBox::GetTitleHeight() const
+{
+ long nHeight;
+ // ask the header bar for the text height (if possible), as the header bar's font is adjusted with
+ // our (and the header's) zoom factor
+ HeaderBar* pHeaderBar = ( (BrowserDataWin*)pDataWin )->pHeaderBar;
+ if ( pHeaderBar )
+ nHeight = pHeaderBar->GetTextHeight();
+ else
+ nHeight = GetTextHeight();
+
+ return nTitleLines ? nTitleLines * nHeight + 4 : 0;
+}
+
+//-------------------------------------------------------------------
+long BrowseBox::CalcReverseZoom(long nVal)
+{
+ if (IsZoom())
+ {
+ const Fraction& rZoom = GetZoom();
+ double n = (double)nVal;
+ n *= (double)rZoom.GetDenominator();
+ n /= (double)rZoom.GetNumerator();
+ nVal = n>0 ? (long)(n + 0.5) : -(long)(-n + 0.5);
+ }
+
+ return nVal;
+}
+
+//-------------------------------------------------------------------
+HeaderBar* BrowseBox::GetHeaderBar() const
+{
+ return ((BrowserDataWin*)pDataWin)->pHeaderBar;
+}
+
+
diff --git a/svtools/source/brwbox/brwbox2.cxx b/svtools/source/brwbox/brwbox2.cxx
new file mode 100644
index 000000000000..916db78bc5c5
--- /dev/null
+++ b/svtools/source/brwbox/brwbox2.cxx
@@ -0,0 +1,2021 @@
+/*************************************************************************
+ *
+ * $RCSfile: brwbox2.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <tools/debug.hxx>
+#include <brwbox.hxx>
+#include "datwin.hxx"
+
+#ifndef _SV_SALGTYPE_HXX
+#include <vcl/salgtype.hxx>
+#endif
+
+#pragma hdrstop
+
+#ifndef _SV_MULTISEL_HXX
+#include <tools/multisel.hxx>
+#endif
+
+#if SUPD<558
+BOOL BrowseBox::m_bFocusOnlyCursor;
+Color BrowseBox::m_aCursorColor;
+BrowserMode BrowseBox::m_nCurrentMode;
+#endif
+
+
+//===================================================================
+
+DBG_NAMEEX(BrowseBox);
+
+//===================================================================
+
+extern const char* BrowseBoxCheckInvariants( const void * pVoid );
+
+DECLARE_LIST( BrowserColumns, BrowserColumn* );
+
+//===================================================================
+
+void BrowseBox::Command( const CommandEvent& rEvt )
+{
+ if ( !((BrowserDataWin*)pDataWin)->bInCommand )
+ Control::Command( rEvt );
+}
+
+//===================================================================
+
+BOOL BrowseBox::IsInCommandEvent() const
+{
+ return ((BrowserDataWin*)pDataWin)->bInCommand;
+}
+
+//===================================================================
+
+void BrowseBox::StateChanged( StateChangedType nStateChange )
+{
+ if ( STATE_CHANGE_INITSHOW == nStateChange )
+ {
+ bBootstrapped = TRUE; // muss zuerst gesetzt werden!
+
+ Resize();
+ if ( bMultiSelection )
+ uRow.pSel->SetTotalRange( Range( 0, nRowCount - 1 ) );
+ if ( nRowCount == 0 )
+ nCurRow = BROWSER_ENDOFSELECTION;
+ else if ( nCurRow == BROWSER_ENDOFSELECTION )
+ nCurRow = 0;
+
+
+ if ( HasFocus() )
+ {
+ bSelectionIsVisible = TRUE;
+ bHasFocus = TRUE;
+ }
+ UpdateScrollbars();
+ AutoSizeLastColumn();
+ CursorMoved();
+ }
+ else if (STATE_CHANGE_ZOOM == nStateChange)
+ {
+ pDataWin->SetZoom(GetZoom());
+ HeaderBar* pHeaderBar = ( (BrowserDataWin*)pDataWin )->pHeaderBar;
+ if (pHeaderBar)
+ pHeaderBar->SetZoom(GetZoom());
+
+ // let the cols calc their new widths and adjust the header bar
+ for ( USHORT nPos = 0; nPos < pCols->Count(); ++nPos )
+ {
+ pCols->GetObject(nPos)->ZoomChanged(GetZoom());
+ if ( pHeaderBar )
+ pHeaderBar->SetItemSize( pCols->GetObject(nPos)->GetId(), pCols->GetObject(nPos)->Width() );
+ }
+
+ // all our controls have to be repositioned
+ Resize();
+ }
+}
+
+//===================================================================
+
+void BrowseBox::Select()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::DoubleClick( const BrowserMouseEvent & )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::CursorMoved()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::QueryColumnResize( USHORT nId, long nWidth )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ return nWidth;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ColumnResized( USHORT nId )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ColumnMoved( USHORT nId )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::StartScroll()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ //((Control*)pDataWin)->HideFocus();
+ DoHideCursor( "StartScroll" );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::EndScroll()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ UpdateScrollbars();
+ AutoSizeLastColumn();
+ DoShowCursor( "EndScroll" );
+}
+
+//-------------------------------------------------------------------
+
+#pragma optimize( "", off )
+
+void BrowseBox::ToggleSelection( BOOL bForce )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // selection highlight-toggling allowed?
+ if ( bHideSelect )
+ return;
+ if ( !bForce &&
+ ( bNotToggleSel || !IsUpdateMode() || !bSelectionIsVisible ) )
+ return;
+//MI, 28.01.98
+// if ( !((BrowserDataWin*)pDataWin)->bHighlightToggle &&
+// !((BrowserDataWin*)pDataWin)->bHighlightAuto )
+// return;
+
+ // only highlight painted areas!
+ bNotToggleSel = TRUE;
+ if ( FALSE && !((BrowserDataWin*)pDataWin)->bInPaint )
+ pDataWin->Update();
+
+ // accumulate areas of rows to highlight
+ RectangleList aHighlightList;
+ long nLastRowInRect = 0; // fuer den CFront
+
+ // Handle-Column nicht highlighten
+ BrowserColumn *pFirstCol = pCols->GetObject(0);
+ long nOfsX = (!pFirstCol || pFirstCol->GetId()) ? 0 : pFirstCol->Width();
+
+ // accumulate old row selection
+ long nBottomRow = nTopRow +
+ pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight();
+ if ( nBottomRow > GetRowCount() && GetRowCount() )
+ nBottomRow = GetRowCount();
+ for ( long nRow = bMultiSelection ? uRow.pSel->FirstSelected() : uRow.nSel;
+ nRow != BROWSER_ENDOFSELECTION && nRow <= nBottomRow;
+ nRow = bMultiSelection ? uRow.pSel->NextSelected() : BROWSER_ENDOFSELECTION )
+ {
+ if ( nRow < nTopRow )
+ continue;
+
+ Rectangle aAddRect(
+ Point( nOfsX, (nRow-nTopRow)*GetDataRowHeight() ),
+ Size( pDataWin->GetSizePixel().Width(), GetDataRowHeight() ) );
+ if ( aHighlightList.Count() && nLastRowInRect == ( nRow - 1 ) )
+ aHighlightList.First()->Union( aAddRect );
+ else
+ aHighlightList.Insert( new Rectangle( aAddRect ), (ULONG) 0 );
+ nLastRowInRect = nRow;
+ }
+
+ // unhighlight the old selection (if any)
+ while ( aHighlightList.Count() )
+ {
+ Rectangle *pRect = aHighlightList.Remove( aHighlightList.Count() - 1 );
+ pDataWin->Invalidate( *pRect );
+ delete pRect;
+ }
+
+ // unhighlight old column selection (if any)
+ for ( long nColId = pColSel ? pColSel->FirstSelected() : BROWSER_ENDOFSELECTION;
+ nColId != BROWSER_ENDOFSELECTION;
+ nColId = pColSel->NextSelected() )
+ {
+ Rectangle aRect( GetFieldRectPixel(nCurRow,
+ pCols->GetObject(nColId)->GetId(),
+ FALSE ) );
+ aRect.Left() -= MIN_COLUMNWIDTH;
+ aRect.Right() += MIN_COLUMNWIDTH;
+ aRect.Top() = 0;
+ aRect.Bottom() = pDataWin->GetOutputSizePixel().Height();
+ pDataWin->Invalidate( aRect );
+ }
+
+ bNotToggleSel = FALSE;
+}
+
+#pragma optimize( "", on )
+
+//-------------------------------------------------------------------
+
+void BrowseBox::DrawCursor()
+{
+ short nCursorHideCount = GetCursorHideCount();
+ BOOL bHidden = bHideCursor || !bSelectionIsVisible ||
+ !IsUpdateMode() || bScrolling || nCurRow < 0;
+
+ if (PaintCursorIfHiddenOnce())
+ bHidden |= ( GetCursorHideCount() > 1 );
+ else
+ bHidden |= ( GetCursorHideCount() > 0 );
+// bHidden |= ( GetCursorHideCount() > 0 ) && !( ( !m_bFocusOnlyCursor && GetCursorHideCount() == 1 ) && !HasFocus() );
+ // hidden if the hide count non-zero
+ // exception : we hided the cursor exactly once in LoseFocus and we have to show the cursor
+
+ // keine Cursor auf Handle-Column
+ if ( nCurColId == 0 )
+ nCurColId = GetColumnId(1);
+
+ // Cursor-Rechteck berechnen
+ Rectangle aCursor;
+ if ( bColumnCursor )
+ {
+ aCursor = GetFieldRectPixel( nCurRow, nCurColId, FALSE );
+ //! --aCursor.Bottom();
+ aCursor.Left() -= MIN_COLUMNWIDTH;
+ aCursor.Right() += 1;
+ aCursor.Bottom() += 1;
+ }
+ else
+ aCursor = Rectangle(
+ Point( ( pCols->Count() && pCols->GetObject(0)->GetId() == 0 ) ?
+ pCols->GetObject(0)->Width() : 0,
+ (nCurRow - nTopRow) * GetDataRowHeight() + 1 ),
+ Size( pDataWin->GetOutputSizePixel().Width() + 1,
+ GetDataRowHeight() - 2 ) );
+ if ( bHLines )
+ {
+ if ( !bMultiSelection )
+ --aCursor.Top();
+ --aCursor.Bottom();
+ }
+
+ //!mi_mac pDataWin->Update();
+
+ if (m_aCursorColor == COL_TRANSPARENT)
+ {
+ // auf diesem Plattformen funktioniert der StarView-Focus richtig
+ if ( bHidden )
+ ((Control*)pDataWin)->HideFocus();
+ else
+ ((Control*)pDataWin)->ShowFocus( aCursor );
+ }
+ else
+ {
+ Color rCol = bHidden ? pDataWin->GetFillColor() : m_aCursorColor;
+ Color aOldFillColor = pDataWin->GetFillColor();
+ Color aOldLineColor = pDataWin->GetLineColor();
+ pDataWin->SetFillColor();
+ pDataWin->SetLineColor( rCol );
+ pDataWin->DrawRect( aCursor );
+ pDataWin->SetLineColor( aOldLineColor );
+ pDataWin->SetFillColor( aOldFillColor );
+ }
+}
+
+//-------------------------------------------------------------------
+
+ULONG BrowseBox::GetColumnWidth( USHORT nId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ USHORT nItemPos = GetColumnPos( nId );
+ if ( nItemPos >= pCols->Count() )
+ return 0;
+ return pCols->GetObject(nItemPos)->Width();
+}
+
+//-------------------------------------------------------------------
+
+USHORT BrowseBox::GetColumnId( USHORT nPos ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( nPos >= pCols->Count() )
+ return 0;
+ return pCols->GetObject(nPos)->GetId();
+}
+
+//-------------------------------------------------------------------
+
+USHORT BrowseBox::GetColumnPos( USHORT nId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ for ( USHORT nPos = 0; nPos < pCols->Count(); ++nPos )
+ if ( pCols->GetObject(nPos)->GetId() == nId )
+ return nPos;
+ return BROWSER_INVALIDID;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::IsFrozen( USHORT nColumnId ) const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ for ( USHORT nPos = 0; nPos < pCols->Count(); ++nPos )
+ if ( pCols->GetObject(nPos)->GetId() == nColumnId )
+ return pCols->GetObject(nPos)->IsFrozen();
+ return FALSE;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ExpandRowSelection( const BrowserMouseEvent& rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ DoHideCursor( "ExpandRowSelection" );
+
+ // expand the last selection
+ if ( bMultiSelection )
+ {
+ Range aJustifiedRange( aSelRange );
+ aJustifiedRange.Justify();
+
+ BOOL bSelectThis =
+ ( bSelect && !aJustifiedRange.IsInside( rEvt.GetRow() ) ) ||
+ ( !bSelect && aJustifiedRange.IsInside( rEvt.GetRow() ) );
+
+ if ( aJustifiedRange.IsInside( rEvt.GetRow() ) )
+ {
+ // down and up
+ while ( rEvt.GetRow() < aSelRange.Max() )
+ { // ZTC/Mac bug - dont put these statemants together!
+ SelectRow( aSelRange.Max(), bSelectThis, TRUE );
+ --aSelRange.Max();
+ }
+ while ( rEvt.GetRow() > aSelRange.Max() )
+ { // ZTC/Mac bug - dont put these statemants together!
+ SelectRow( aSelRange.Max(), bSelectThis, TRUE );
+ ++aSelRange.Max();
+ }
+ }
+ else
+ {
+ // up and down
+ BOOL bOldSelecting = bSelecting;
+ bSelecting = TRUE;
+ while ( rEvt.GetRow() < aSelRange.Max() )
+ { // ZTC/Mac bug - dont put these statemants together!
+ --aSelRange.Max();
+ if ( !IsRowSelected( aSelRange.Max() ) )
+ {
+ SelectRow( aSelRange.Max(), bSelectThis, TRUE );
+ bSelect = TRUE;
+ }
+ }
+ while ( rEvt.GetRow() > aSelRange.Max() )
+ { // ZTC/Mac bug - dont put these statemants together!
+ ++aSelRange.Max();
+ if ( !IsRowSelected( aSelRange.Max() ) )
+ {
+ SelectRow( aSelRange.Max(), bSelectThis, TRUE );
+ bSelect = TRUE;
+ }
+ }
+ bSelecting = bOldSelecting;
+ if ( bSelect )
+ Select();
+ }
+ }
+ else
+ if ( !bMultiSelection || !IsRowSelected( rEvt.GetRow() ) )
+ SelectRow( rEvt.GetRow(), TRUE );
+
+ GoToRow( rEvt.GetRow(), FALSE );
+ DoShowCursor( "ExpandRowSelection" );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::Resize()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ if ( !bBootstrapped && IsReallyVisible() )
+ BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
+ if ( !pCols->Count() )
+ {
+ ((BrowserDataWin*)pDataWin)->bResizeOnPaint = TRUE;
+ return;
+ }
+ ((BrowserDataWin*)pDataWin)->bResizeOnPaint = FALSE;
+
+ // calc the size of the scrollbars
+ // (we can't ask the scrollbars for their widths cause if we're zoomed they still have to be
+ // resized - which is done in UpdateScrollbars)
+ ULONG nSBSize = GetSettings().GetStyleSettings().GetScrollBarSize();
+ if (IsZoom())
+ nSBSize = (ULONG)(nSBSize * (double)GetZoom());
+
+ long nSize = pDataWin->GetPosPixel().Y();
+ if( !((BrowserDataWin*)pDataWin)->bNoHScroll )
+ nSize += aHScroll.GetSizePixel().Height();
+ if ( GetOutputSizePixel().Height() < nSize ) return;
+
+ DoHideCursor( "Resize" );
+ USHORT nOldVisibleRows =
+ (USHORT)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
+
+ // did we need a horiz. scroll bar oder gibt es eine Control Area?
+ if ( !((BrowserDataWin*)pDataWin)->bNoHScroll &&
+ ( ( pCols->Count() - FrozenColCount() ) > 1 || nControlAreaWidth > 0 ) )
+ aHScroll.Show();
+ else
+ aHScroll.Hide();
+
+ // calculate the size of the data window
+ long nDataHeight = GetOutputSizePixel().Height() - GetTitleHeight();
+ if ( aHScroll.IsVisible() )
+ nDataHeight -= nSBSize;
+
+ long nDataWidth = GetOutputSizePixel().Width();
+ if ( pVScroll->IsVisible() )
+ nDataWidth -= nSBSize;
+
+ // adjust position and size of data window
+ pDataWin->SetPosSizePixel(
+ Point( 0, GetTitleHeight() ),
+ Size( nDataWidth, nDataHeight ) );
+
+ USHORT nVisibleRows =
+ (USHORT)(pDataWin->GetOutputSizePixel().Height() / GetDataRowHeight() + 1);
+
+ // TopRow ist unveraendert, aber die Anzahl sichtbarer Zeilen hat sich
+ // geaendert
+ if ( nVisibleRows != nOldVisibleRows )
+ VisibleRowsChanged(nTopRow, nVisibleRows);
+
+ UpdateScrollbars();
+
+ // Control-Area
+ Rectangle aInvalidArea( GetControlArea() );
+ aInvalidArea.Right() = GetOutputSizePixel().Width();
+ aInvalidArea.Left() = 0;
+ Invalidate( aInvalidArea );
+
+ // external header-bar
+ HeaderBar* pHeaderBar = ( (BrowserDataWin*)pDataWin )->pHeaderBar;
+ if ( pHeaderBar )
+ {
+ // Handle-Column beruecksichtigen
+ BrowserColumn *pFirstCol = pCols->GetObject(0);
+ long nOfsX = pFirstCol->GetId() ? 0 : pFirstCol->Width();
+ pHeaderBar->SetPosPixel( Point( nOfsX, 0 ) );
+ pHeaderBar->SetSizePixel( Size( GetOutputSizePixel().Width() - nOfsX, GetTitleHeight() ) );
+ }
+
+ AutoSizeLastColumn(); // adjust last column width
+ DoShowCursor( "Resize" );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::Paint( const Rectangle& rRect )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // initializations
+ if ( !bBootstrapped && IsReallyVisible() )
+ BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
+ if ( !pCols->Count() )
+ return;
+
+ BrowserColumn *pFirstCol = pCols->GetObject(0);
+ BOOL bHandleCol = pFirstCol && pFirstCol->GetId() == 0;
+ BOOL bHeaderBar = ((BrowserDataWin*)pDataWin)->pHeaderBar != NULL;
+
+ // draw delimitational lines
+ if ( !((BrowserDataWin*)pDataWin)->bNoHScroll )
+ DrawLine( Point( 0, aHScroll.GetPosPixel().Y() ),
+ Point( GetOutputSizePixel().Width(),
+ aHScroll.GetPosPixel().Y() ) );
+
+ if ( nTitleLines )
+ {
+ if ( !bHeaderBar )
+ DrawLine( Point( 0, GetTitleHeight() - 1 ),
+ Point( GetOutputSizePixel().Width(),
+ GetTitleHeight() - 1 ) );
+ else if ( bHandleCol )
+ DrawLine( Point( 0, GetTitleHeight() - 1 ),
+ Point( pFirstCol->Width(), GetTitleHeight() - 1 ) );
+ }
+
+ // Title Bar
+ // Wenn es eine Handle Column gibt und die Headerbar verfuegbar ist, dann nur
+ // die HandleColumn
+ // Handle-Column beruecksichtigen
+ if ( nTitleLines && (!bHeaderBar || bHandleCol) )
+ {
+ // iterate through columns to redraw
+ long nX = 0;
+ USHORT nCol;
+ for ( nCol = 0;
+ nCol < pCols->Count() && nX < rRect.Right();
+ ++nCol )
+ {
+ // skip invisible colums between frozen and scrollable area
+ if ( nCol < nFirstCol && !pCols->GetObject(nCol)->IsFrozen() )
+ nCol = nFirstCol;
+
+ // nur die HandleCol ?
+ if (bHeaderBar && bHandleCol && nCol > 0)
+ break;
+
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+
+ // draw the column and increment position
+ if ( pCol->Width() > 4 )
+ {
+ ButtonFrame aButtonFrame( Point( nX, 0 ),
+ Size( pCol->Width()-1, GetTitleHeight()-1 ),
+ pCol->Title(), FALSE, FALSE,
+ 0 != (BROWSER_COLUMN_TITLEABBREVATION&pCol->Flags()) );
+ aButtonFrame .Draw( *this );
+ DrawLine( Point( nX + pCol->Width() - 1, 0 ),
+ Point( nX + pCol->Width() - 1, GetTitleHeight()-1 ) );
+ }
+ else
+ {
+ Color aOldFillColor = GetFillColor();
+ SetFillColor( Color( COL_BLACK ) );
+ DrawRect( Rectangle( Point( nX, 0 ), Size( pCol->Width(), GetTitleHeight() - 1 ) ) );
+ SetFillColor( aOldFillColor );
+ }
+
+ // skip column
+ nX += pCol->Width();
+ }
+
+ // retouching
+ if ( !bHeaderBar && nCol == pCols->Count() )
+ {
+ const StyleSettings &rSettings = GetSettings().GetStyleSettings();
+ Color aColFace( rSettings.GetFaceColor() );
+ Color aOldFillColor = GetFillColor();
+ Color aOldLineColor = GetLineColor();
+ SetFillColor( aColFace );
+ SetLineColor( aColFace );
+ DrawRect( Rectangle(
+ Point( nX, 0 ),
+ Point( rRect.Right(), GetTitleHeight() - 2 ) ) );
+ SetFillColor( aOldLineColor );
+ SetLineColor( aOldFillColor );
+ }
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::PaintRow( OutputDevice &rDev, const Rectangle &rRect )
+{
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, ULONG nFlags )
+{
+ BOOL bDrawSelection = (nFlags & WINDOW_DRAW_NOSELECTION) == 0;
+
+ // we need pixel coordinates
+ Size aRealSize = pDev->LogicToPixel(rSize);
+ Point aRealPos = pDev->LogicToPixel(rPos);
+
+ if ((rSize.Width() < 3) || (rSize.Height() < 3))
+ // we want to have two pixels frame ...
+ return;
+
+ Font aFont = GetDataWindow().GetDrawPixelFont( pDev );
+ // the 'normal' painting uses always the data window as device to output to, so we have to calc the new font
+ // relative to the data wins current settings
+
+ pDev->Push();
+ pDev->SetMapMode();
+ pDev->SetFont( aFont );
+
+ // draw a frame
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ pDev->SetLineColor(rStyleSettings.GetDarkShadowColor());
+ pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()),
+ Point(aRealPos.X(), aRealPos.Y() + aRealSize.Height() - 1));
+ pDev->DrawLine(Point(aRealPos.X(), aRealPos.Y()),
+ Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y()));
+ pDev->SetLineColor(rStyleSettings.GetShadowColor());
+ pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + 1),
+ Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1));
+ pDev->DrawLine(Point(aRealPos.X() + aRealSize.Width() - 1, aRealPos.Y() + aRealSize.Height() - 1),
+ Point(aRealPos.X() + 1, aRealPos.Y() + aRealSize.Height() - 1));
+
+ HeaderBar* pBar = ((BrowserDataWin*)pDataWin)->pHeaderBar;
+
+ // we're drawing onto a foreign device, so we have to fake the DataRowHeight for the subsequent ImplPaintData
+ // (as it is based on the settings of our data window, not the foreign device)
+ if (!nDataRowHeight)
+ ImpGetDataRowHeight();
+ long nHeightLogic = PixelToLogic(Size(0, nDataRowHeight), MAP_10TH_MM).Height();
+ long nForeignHeightPixel = pDev->LogicToPixel(Size(0, nHeightLogic), MAP_10TH_MM).Height();
+
+ long nOriginalHeight = nDataRowHeight;
+ nDataRowHeight = nForeignHeightPixel;
+
+ // this counts for the column widths, too
+ USHORT nPos;
+ for ( nPos = 0; nPos < pCols->Count(); ++nPos )
+ {
+ BrowserColumn* pCurrent = pCols->GetObject(nPos);
+
+ long nWidthLogic = PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width();
+ long nForeignWidthPixel = pDev->LogicToPixel(Size(nWidthLogic, 0), MAP_10TH_MM).Width();
+
+ pCurrent->SetWidth(nForeignWidthPixel, GetZoom());
+ if ( pBar )
+ pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() );
+ }
+
+ // a smaller area for the content
+ ++aRealPos.X();
+ ++aRealPos.Y();
+ aRealSize.Width() -= 2;
+ aRealSize.Height() -= 2;
+
+ // let the header bar draw itself
+ if ( pBar )
+ {
+ // the title height with respect to the font set for the given device
+ long nTitleHeight = PixelToLogic(Size(0, GetTitleHeight()), MAP_10TH_MM).Height();
+ nTitleHeight = pDev->LogicToPixel(Size(0, nTitleHeight), MAP_10TH_MM).Height();
+
+ BrowserColumn* pFirstCol = pCols->Count() ? pCols->GetObject(0) : NULL;
+
+ Point aHeaderPos(pFirstCol && (pFirstCol->GetId() == 0) ? pFirstCol->Width() : 0, 0);
+ Size aHeaderSize(aRealSize.Width() - aHeaderPos.X(), nTitleHeight);
+
+ aHeaderPos += aRealPos;
+ // do this before converting to logics !
+
+ // the header's draw expects logic coordinates, again
+ aHeaderPos = pDev->PixelToLogic(aHeaderPos);
+ aHeaderSize = pDev->PixelToLogic(aHeaderSize);
+
+ pBar->Draw(pDev, aHeaderPos, aHeaderSize, nFlags);
+
+ // draw the "upper left cell" (the intersection between the header bar and the handle column)
+ if (( pFirstCol->GetId() == 0 ) && ( pFirstCol->Width() > 4 ))
+ {
+ ButtonFrame aButtonFrame( aRealPos,
+ Size( pFirstCol->Width()-1, nTitleHeight-1 ),
+ pFirstCol->Title(), FALSE, FALSE, FALSE);
+ aButtonFrame.Draw( *pDev );
+
+ Color aOldColor = pDev->GetLineColor();
+ pDev->SetLineColor( Color( COL_BLACK ) );
+
+ pDev->DrawLine( Point( aRealPos.X(), aRealPos.Y() + nTitleHeight-1 ),
+ Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) );
+ pDev->DrawLine( Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() ),
+ Point( aRealPos.X() + pFirstCol->Width() - 1, aRealPos.Y() + nTitleHeight-1 ) );
+
+ pDev->SetLineColor( aOldColor );
+ }
+
+ aRealPos.Y() += aHeaderSize.Height();
+ aRealSize.Height() -= aHeaderSize.Height();
+ }
+
+ // draw our own content (with clipping)
+ Region aRegion(Rectangle(aRealPos, aRealSize));
+ pDev->SetClipRegion( pDev->PixelToLogic( aRegion ) );
+
+ // do we have to paint the background
+ BOOL bBackground = !(nFlags & WINDOW_DRAW_NOBACKGROUND) && GetDataWindow().IsControlBackground();
+ if ( bBackground )
+ {
+ Rectangle aRect( aRealPos, aRealSize );
+ pDev->SetFillColor( GetDataWindow().GetControlBackground() );
+ pDev->DrawRect( aRect );
+ }
+
+ ImplPaintData( *pDev, Rectangle( aRealPos, aRealSize ), TRUE, bDrawSelection );
+
+ // restore the column widths/data row height
+ nDataRowHeight = nOriginalHeight;
+ for ( nPos = 0; nPos < pCols->Count(); ++nPos )
+ {
+ BrowserColumn* pCurrent = pCols->GetObject(nPos);
+
+ long nForeignWidthLogic = pDev->PixelToLogic(Size(pCurrent->Width(), 0), MAP_10TH_MM).Width();
+ long nWidthPixel = LogicToPixel(Size(nForeignWidthLogic, 0), MAP_10TH_MM).Width();
+
+ pCurrent->SetWidth(nWidthPixel, GetZoom());
+ if ( pBar )
+ pBar->SetItemSize( pCurrent->GetId(), pCurrent->Width() );
+ }
+
+ pDev->Pop();
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ImplPaintData(OutputDevice& _rOut, const Rectangle& _rRect, BOOL _bForeignDevice, BOOL _bDrawSelections)
+{
+ Point aOverallAreaPos = _bForeignDevice ? _rRect.TopLeft() : Point(0,0);
+ Size aOverallAreaSize = _bForeignDevice ? _rRect.GetSize() : GetDataWindow().GetOutputSizePixel();
+ Point aOverallAreaBRPos = _bForeignDevice ? _rRect.BottomRight() : Point( aOverallAreaSize.Width(), aOverallAreaSize.Height() );
+
+ long nDataRowHeigt = GetDataRowHeight();
+
+ // compute relative rows to redraw
+ ULONG nRelTopRow = _bForeignDevice ? 0 : ((ULONG)_rRect.Top() / nDataRowHeigt);
+ ULONG nRelBottomRow = (ULONG)(_bForeignDevice ? aOverallAreaSize.Height() : _rRect.Bottom()) / nDataRowHeigt;
+
+ // cache frequently used values
+ Point aPos( aOverallAreaPos.X(), nRelTopRow * nDataRowHeigt + aOverallAreaPos.Y() );
+ _rOut.SetLineColor( Color( COL_WHITE ) );
+ const StyleSettings &rSettings = _rOut.GetSettings().GetStyleSettings();
+ const Color &rHighlightTextColor = rSettings.GetHighlightTextColor();
+ const Color &rHighlightFillColor = rSettings.GetHighlightColor();
+ Color aOldTextColor = _rOut.GetTextColor();
+ Color aOldFillColor = _rOut.GetFillColor();
+ Color aOldLineColor = _rOut.GetLineColor();
+ long nHLineX = 0 == pCols->GetObject(0)->GetId()
+ ? pCols->GetObject(0)->Width()
+ : 0;
+ nHLineX += aOverallAreaPos.X();
+
+ // redraw the invalid fields
+ BOOL bRetouching = FALSE;
+ for ( ULONG nRelRow = nRelTopRow;
+ nRelRow <= nRelBottomRow && (ULONG)nTopRow+nRelRow < (ULONG)nRowCount;
+ ++nRelRow, aPos.Y() += nDataRowHeigt )
+ {
+ // get row
+ // Zur Sicherheit auf zul"assigen Bereich abfragen:
+ DBG_ASSERT( (USHORT)(nTopRow+nRelRow) >= 0 && (USHORT)(nTopRow+nRelRow) < nRowCount,
+ "BrowseBox::ImplPaintData: invalid seek" );
+ if ( (nTopRow+nRelRow) < 0 || (USHORT)(nTopRow+nRelRow) >= nRowCount )
+ continue;
+
+ // prepare row
+ ULONG nCurRow = nTopRow+nRelRow;
+ if ( !SeekRow( nCurRow) )
+ DBG_ERROR("BrowseBox::ImplPaintData: SeekRow gescheitert");
+ _rOut.SetClipRegion();
+ aPos.X() = aOverallAreaPos.X();
+
+
+ // #73325# don't paint the row outside the painting rectangle (DG)
+ // prepare auto-highlight
+ Rectangle aRowRect( Point( _rRect.TopLeft().X(), aPos.Y() ),
+ Size( _rRect.GetSize().Width(), nDataRowHeigt ) );
+ PaintRow( _rOut, aRowRect );
+
+ BOOL bRowAutoHighlight = _bDrawSelections
+ && !bHideSelect
+ && ((BrowserDataWin&)GetDataWindow()).bHighlightAuto
+ && IsRowSelected( nCurRow );
+ if ( bRowAutoHighlight )
+ {
+ _rOut.SetTextColor( rHighlightTextColor );
+ _rOut.SetFillColor( rHighlightFillColor );
+ _rOut.SetLineColor();
+ _rOut.DrawRect( aRowRect );
+ }
+
+ // iterate through columns to redraw
+ USHORT nCol;
+ for ( nCol = 0; nCol < pCols->Count(); ++nCol )
+ {
+ // get column
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+
+ // at end of invalid area
+ if ( aPos.X() >= _rRect.Right() )
+ break;
+
+ // skip invisible colums between frozen and scrollable area
+ if ( nCol < nFirstCol && !pCol->IsFrozen() )
+ {
+ nCol = nFirstCol;
+ pCol = pCols->GetObject(nCol);
+ if (!pCol)
+ { // FS - 21.05.99 - 66325
+ // ist zwar eigentlich woanders (an der richtigen Stelle) gefixt, aber sicher ist sicher ...
+ DBG_ERROR("BrowseBox::PaintData : nFirstCol is probably invalid !");
+ break;
+ }
+ }
+
+ // prepare Column-AutoHighlight
+ BOOL bColAutoHighlight = _bDrawSelections
+ && bColumnCursor
+ && IsColumnSelected( pCol->GetId() );
+ if ( bColAutoHighlight )
+ {
+ _rOut.SetClipRegion();
+ _rOut.SetTextColor( rHighlightTextColor );
+ _rOut.SetFillColor( rHighlightFillColor );
+ _rOut.SetLineColor();
+ Rectangle aFieldRect( aPos,
+ Size( pCol->Width(), nDataRowHeigt ) );
+ _rOut.DrawRect( aFieldRect );
+ }
+
+ if (!m_bFocusOnlyCursor && (pCol->GetId() == GetCurColumnId()) && (nCurRow == GetCurRow()))
+ DrawCursor();
+
+ // draw a single field
+ // #63864#, Sonst wird auch etwas gezeichnet, bsp Handle Column
+ if (pCol->Width())
+ {
+ // clip the column's output to the field area
+ if (_bForeignDevice)
+ { // (not neccessary if painting onto the data window)
+ Size aFieldSize(pCol->Width(), nDataRowHeigt);
+
+ if (aPos.X() + aFieldSize.Width() > aOverallAreaBRPos.X())
+ aFieldSize.Width() = aOverallAreaBRPos.X() - aPos.X();
+
+ if (aPos.Y() + aFieldSize.Height() > aOverallAreaBRPos.Y() + 1)
+ {
+ // for non-handle cols we don't clip vertically : we just don't draw the cell if the line isn't completely visible
+ if (pCol->GetId() != 0)
+ continue;
+ aFieldSize.Height() = aOverallAreaBRPos.Y() + 1 - aPos.Y();
+ }
+
+ Region aClipToField(Rectangle(aPos, aFieldSize));
+ _rOut.SetClipRegion(aClipToField);
+ }
+ pCol->Draw( *this, _rOut, aPos, FALSE );
+ if (_bForeignDevice)
+ _rOut.SetClipRegion();
+ }
+
+ // reset Column-auto-highlight
+ if ( bColAutoHighlight )
+ {
+ _rOut.SetTextColor( aOldTextColor );
+ _rOut.SetFillColor( aOldFillColor );
+ _rOut.SetLineColor( aOldLineColor );
+ }
+
+ // skip column
+ aPos.X() += pCol->Width();
+ }
+
+ if ( nCol == pCols->Count() )
+ bRetouching = TRUE;
+
+ // reset auto-highlight
+ if ( bRowAutoHighlight )
+ {
+ _rOut.SetTextColor( aOldTextColor );
+ _rOut.SetFillColor( aOldFillColor );
+ _rOut.SetLineColor( aOldLineColor );
+ }
+
+ if ( bHLines )
+ {
+ // draw horizontal delimitation lines
+ _rOut.SetClipRegion();
+ Color aOldColor = _rOut.GetLineColor();
+ _rOut.SetLineColor( aLineColor );
+ long nY = aPos.Y() + nDataRowHeigt - 1;
+ if (nY <= aOverallAreaBRPos.Y())
+ _rOut.DrawLine( Point( nHLineX, nY ),
+ Point( bVLines
+ ? min(long(long(aPos.X()) - 1), aOverallAreaBRPos.X())
+ : aOverallAreaBRPos.X(),
+ nY ) );
+ _rOut.SetLineColor( aOldColor );
+ }
+ }
+
+ if (aPos.Y() > aOverallAreaBRPos.Y() + 1)
+ aPos.Y() = aOverallAreaBRPos.Y() + 1;
+ // needed for some of the following drawing
+
+ // retouching
+ _rOut.SetClipRegion();
+ aOldLineColor = _rOut.GetLineColor();
+ aOldFillColor = _rOut.GetFillColor();
+ _rOut.SetFillColor( rSettings.GetFaceColor() );
+ if ( pCols->Count() && ( pCols->GetObject(0)->GetId() == 0 ) && ( aPos.Y() <= _rRect.Bottom() ) )
+ {
+ // fill rectangle gray below handle column
+ // DG: fill it only until the end of the drawing rect and not to the end, as this may overpaint handle columns
+ _rOut.SetLineColor( Color( COL_BLACK ) );
+ _rOut.DrawRect( Rectangle(
+ Point( aOverallAreaPos.X() - 1, aPos.Y() - 1 ),
+ Point( aOverallAreaPos.X() + pCols->GetObject(0)->Width() - 1,
+ _rRect.Bottom() + 1) ) );
+ }
+ _rOut.SetFillColor( aOldFillColor );
+
+ // draw vertical delimitational line between frozen and scrollable cols
+ _rOut.SetLineColor( COL_BLACK );
+ long nFrozenWidth = GetFrozenWidth()-1;
+ _rOut.DrawLine( Point( aOverallAreaPos.X() + nFrozenWidth, aPos.Y() ),
+ Point( aOverallAreaPos.X() + nFrozenWidth, bHLines
+ ? aPos.Y() - 1
+ : aOverallAreaBRPos.Y() ) );
+
+ // draw vertical delimitational lines?
+ if ( bVLines )
+ {
+ _rOut.SetLineColor( aLineColor );
+ Point aVertPos( aOverallAreaPos.X() - 1, aOverallAreaPos.Y() );
+ long nDeltaY = aOverallAreaBRPos.Y();
+ for ( USHORT nCol = 0; nCol < pCols->Count(); ++nCol )
+ {
+ // get column
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+
+ // skip invisible colums between frozen and scrollable area
+ if ( nCol < nFirstCol && !pCol->IsFrozen() )
+ {
+ nCol = nFirstCol;
+ pCol = pCols->GetObject(nCol);
+ }
+
+ // skip column
+ aVertPos.X() += pCol->Width();
+
+ // at end of invalid area
+ // invalid area is first reached when X > Right
+ // and not >=
+ if ( aVertPos.X() > _rRect.Right() )
+ break;
+
+ // draw a single line
+ if ( pCol->GetId() != 0 )
+ _rOut.DrawLine( aVertPos, Point( aVertPos.X(),
+ bHLines
+ ? aPos.Y() - 1
+ : aPos.Y() + nDeltaY ) );
+ }
+ }
+
+ _rOut.SetLineColor( aOldLineColor );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::PaintData( Window& rWin, const Rectangle& rRect )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ if ( !bBootstrapped && IsReallyVisible() )
+ BrowseBox::StateChanged( STATE_CHANGE_INITSHOW );
+
+ // initializations
+ if ( !pCols || !pCols->Count() || !rWin.IsUpdateMode() )
+ return;
+ if ( ((BrowserDataWin*)pDataWin)->bResizeOnPaint )
+ Resize();
+ // MI: wer war das denn? Window::Update();
+
+ ImplPaintData(rWin, rRect, FALSE, TRUE);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::UpdateScrollbars()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( !bBootstrapped || !IsUpdateMode() )
+ return;
+
+ // Rekursionsschutz
+ BrowserDataWin *pBDW = (BrowserDataWin*) pDataWin;
+ if ( pBDW->bInUpdateScrollbars )
+ {
+ pBDW->bHadRecursion = TRUE;
+ return;
+ }
+ pBDW->bInUpdateScrollbars = TRUE;
+
+ // the size of the corner window (and the width of the VSB/height of the HSB)
+ ULONG nCornerSize = GetSettings().GetStyleSettings().GetScrollBarSize();
+ if (IsZoom())
+ nCornerSize = (ULONG)(nCornerSize * (double)GetZoom());
+
+ // needs VScroll?
+ long nMaxRows = (pDataWin->GetSizePixel().Height()) / GetDataRowHeight();
+ BOOL bNeedsVScroll = ((BrowserDataWin*)pDataWin)->bAutoVScroll
+ ? nTopRow || nRowCount > nMaxRows
+ : TRUE;
+ Size aDataWinSize = pDataWin->GetSizePixel();
+ if ( !bNeedsVScroll )
+ {
+ if ( pVScroll->IsVisible() )
+ {
+ pVScroll->Hide();
+ Size aNewSize( aDataWinSize );
+ aNewSize.Width() = GetOutputSizePixel().Width();
+ aDataWinSize = aNewSize;
+ }
+ }
+ else if ( !pVScroll->IsVisible() )
+ {
+ Size aNewSize( aDataWinSize );
+ aNewSize.Width() = GetOutputSizePixel().Width() - nCornerSize;
+ aDataWinSize = aNewSize;
+ }
+
+ // needs HScroll?
+ ULONG nLastCol = GetColumnAtXPosPixel( aDataWinSize.Width() - 1 );
+
+ USHORT nFrozenCols = FrozenColCount();
+ BOOL bNeedsHScroll = ((BrowserDataWin*)pDataWin)->bAutoHScroll
+ ? nFirstCol > nFrozenCols || nLastCol <= pCols->Count()
+ : !((BrowserDataWin*)pDataWin)->bNoHScroll;
+ if ( !bNeedsHScroll )
+ {
+ if ( aHScroll.IsVisible() )
+ {
+ aHScroll.Hide();
+ Size aNewSize( aDataWinSize );
+ aNewSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight();
+ aDataWinSize = aNewSize;
+ }
+ }
+ else if ( !aHScroll.IsVisible() )
+ {
+ Size aNewSize( aDataWinSize );
+ aNewSize.Height() = GetOutputSizePixel().Height() - GetTitleHeight() - nCornerSize;
+ aDataWinSize = aNewSize;
+ }
+
+ // adjust position and Width of horizontal scrollbar
+ ULONG nHScrX = nControlAreaWidth == USHRT_MAX
+ ? GetFrozenWidth() - 1
+ : nControlAreaWidth;
+
+ aHScroll.SetPosSizePixel(
+ Point( nHScrX, GetOutputSizePixel().Height() - nCornerSize ),
+ Size( aDataWinSize.Width() - nHScrX, nCornerSize ) );
+
+ // Scrollable Columns insgesamt
+ short nScrollCols = short(pCols->Count()) - (short)nFrozenCols;
+ /*short nVisibleHSize= max(nLastCol == BROWSER_INVALIDID
+ ? pCols->Count() - nFirstCol -1
+ : nLastCol - nFirstCol - 1, 0);
+
+ aHScroll.SetVisibleSize( nVisibleHSize );
+ aHScroll.SetRange( Range( 0, Max( min(nScrollCols, nVisibleHSize), (short)0 ) ) );
+ if ( bNeedsHScroll && !aHScroll.IsVisible() )
+ aHScroll.Show();*/
+
+ // Sichtbare Columns
+ short nVisibleHSize = nLastCol == BROWSER_INVALIDID
+ ? (short)( pCols->Count() - nFirstCol )
+ : (short)( nLastCol - nFirstCol );
+
+ short nRange = Max( nScrollCols, (short)0 );
+ aHScroll.SetVisibleSize( nVisibleHSize );
+ aHScroll.SetRange( Range( 0, nRange ));
+ if ( bNeedsHScroll && !aHScroll.IsVisible() )
+ aHScroll.Show();
+
+ // adjust position and height of vertical scrollbar
+ pVScroll->SetPageSize( nMaxRows );
+
+ if ( nTopRow > nRowCount )
+ {
+ nTopRow = nRowCount - 1;
+ DBG_ERROR("BrowseBox: nTopRow > nRowCount");
+ }
+
+ if ( pVScroll->GetThumbPos() != nTopRow )
+ pVScroll->SetThumbPos( nTopRow );
+ long nVisibleSize = Min( Min( nRowCount, nMaxRows ), long(nRowCount-nTopRow) );
+ pVScroll->SetVisibleSize( nVisibleSize ? nVisibleSize : 1 );
+ pVScroll->SetRange( Range( 0, nRowCount ) );
+ pVScroll->SetPosSizePixel(
+ Point( aDataWinSize.Width(), GetTitleHeight() ),
+ Size( nCornerSize, aDataWinSize.Height() ) );
+ if ( nRowCount <
+ long( aDataWinSize.Height() / GetDataRowHeight() ) )
+ ScrollRows( -nTopRow );
+ long nDelta = nCornerSize;
+ if ( bNeedsVScroll && !pVScroll->IsVisible() )
+ pVScroll->Show();
+
+ pDataWin->SetSizePixel( aDataWinSize );
+
+ // needs corner-window?
+ // (do that AFTER positioning BOTH scrollbars)
+ if ( aHScroll.IsVisible() && pVScroll && pVScroll->IsVisible() )
+ {
+ if ( !( (BrowserDataWin*)pDataWin )->pCornerWin )
+ ( (BrowserDataWin*)pDataWin )->pCornerWin = new ScrollBarBox( this, WB_3DLOOK );
+ ( (BrowserDataWin*)pDataWin )->pCornerWin->SetPosSizePixel(
+ Point( pVScroll->GetPosPixel().X(), aHScroll.GetPosPixel().Y() ),
+ Size( nCornerSize, nCornerSize ) );
+ ( (BrowserDataWin*)pDataWin )->pCornerWin->Show();
+ }
+ else
+ DELETEZ( ( (BrowserDataWin*)pDataWin )->pCornerWin );
+
+ // ggf. Headerbar mitscrollen
+ if ( ((BrowserDataWin*)pDataWin)->pHeaderBar )
+ {
+ long nWidth = 0;
+ for ( USHORT nCol = 0;
+ nCol < pCols->Count() && nCol < nFirstCol;
+ ++nCol )
+ {
+ // HandleColumn nicht
+ if ( pCols->GetObject(nCol)->GetId() )
+ nWidth += pCols->GetObject(nCol)->Width();
+ }
+
+ ((BrowserDataWin*)pDataWin)->pHeaderBar->SetOffset( nWidth );
+ }
+
+ pBDW->bInUpdateScrollbars = FALSE;
+ if ( pBDW->bHadRecursion )
+ {
+ pBDW->bHadRecursion = FALSE;
+ UpdateScrollbars();
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::Invalidate()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // readjust cursor and selection
+ if ( bMultiSelection )
+ uRow.pSel->SetTotalRange( Range( 0, nRowCount-1 ) );
+ else
+ uRow.nSel = Min( uRow.nSel, (long)(nRowCount-1) );
+ nCurRow = Min( nCurRow, (long)(nRowCount-1 ));
+
+ // BowseBox::Resize(); if Size not set, last Culumn will be cuttet ?!?
+ Control::Invalidate(INVALIDATE_NOCHILDREN /*OV*/ );
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetUpdateMode( BOOL bUpdate )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ BOOL bWasUpdate = IsUpdateMode();
+ if ( bWasUpdate == bUpdate )
+ return;
+
+ Control::SetUpdateMode( bUpdate );
+ // OV
+ // Wenn an der BrowseBox WB_CLIPCHILDREN gesetzt ist (wg. Flackerminimierung),
+ // wird das Datenfenster nicht von SetUpdateMode invalidiert.
+ if( bUpdate )
+ ((BrowserDataWin*)pDataWin)->Invalidate();
+ ((BrowserDataWin*)pDataWin)->SetUpdateMode( bUpdate );
+
+
+ if ( bUpdate )
+ {
+ if ( bBootstrapped )
+ {
+ UpdateScrollbars();
+ AutoSizeLastColumn();
+ }
+ DoShowCursor( "SetUpdateMode" );
+ }
+ else
+ DoHideCursor( "SetUpdateMode" );
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::GetUpdateMode() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return ((BrowserDataWin*)pDataWin)->IsUpdateMode();
+}
+
+//-------------------------------------------------------------------
+
+long BrowseBox::GetFrozenWidth() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ long nWidth = 0;
+ for ( USHORT nCol = 0;
+ nCol < pCols->Count() && pCols->GetObject(nCol)->IsFrozen();
+ ++nCol )
+ nWidth += pCols->GetObject(nCol)->Width();
+ return nWidth;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::ColumnInserted( USHORT nPos )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( pColSel )
+ pColSel->Insert( nPos );
+ UpdateScrollbars();
+}
+
+//-------------------------------------------------------------------
+
+USHORT BrowseBox::FrozenColCount() const
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ USHORT nCol;
+ for ( nCol = 0;
+ nCol < pCols->Count() && pCols->GetObject(nCol)->IsFrozen();
+ ++nCol )
+ /* empty loop */;
+ return nCol;
+}
+
+//-------------------------------------------------------------------
+
+IMPL_LINK(BrowseBox,ScrollHdl,ScrollBar*,pBar)
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( pBar->GetDelta() == 0 )
+ return 0;
+
+ if ( pBar->GetDelta() < 0 && ((BrowserDataWin*)pDataWin)->bNoScrollBack )
+ {
+ UpdateScrollbars();
+ return 0;
+ }
+
+ if ( pBar == &aHScroll )
+ ScrollColumns( aHScroll.GetDelta() );
+ if ( pBar == pVScroll )
+ ScrollRows( pVScroll->GetDelta() );
+
+ return 0;
+}
+
+//-------------------------------------------------------------------
+
+IMPL_LINK( BrowseBox,EndScrollHdl,ScrollBar*, pBar )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // kein Focus grabben!
+ /// GrabFocus();
+
+ if ( /*pBar->GetDelta() <= 0 &&*/ ((BrowserDataWin*)pDataWin)->bNoScrollBack )
+ {
+ // UpdateScrollbars();
+ EndScroll();
+ return 0;
+ }
+
+ return 0;
+}
+
+//-------------------------------------------------------------------
+
+IMPL_LINK( BrowseBox, StartDragHdl, HeaderBar*, pBar )
+{
+ pBar->SetDragSize( pDataWin->GetOutputSizePixel().Height() );
+ return 0;
+}
+
+//-------------------------------------------------------------------
+// MI: es wurde immer nur die 1. Spalte resized
+#pragma optimize("elg",off)
+
+void BrowseBox::MouseButtonDown( const MouseEvent& rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ GrabFocus();
+
+ // onl< mouse events in the title-line are supported
+ const Point &rEvtPos = rEvt.GetPosPixel();
+ if ( rEvtPos.Y() >= GetTitleHeight() )
+ return;
+
+ long nX = 0;
+ long nWidth = GetOutputSizePixel().Width();
+ for ( USHORT nCol = 0; nCol < pCols->Count() && nX < nWidth; ++nCol )
+ {
+ // is this column visible?
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+ if ( pCol->IsFrozen() || nCol >= nFirstCol )
+ {
+ // compute right end of column
+ long nR = nX + pCol->Width() - 1;
+
+ // at the end of a column (and not handle column)?
+ if ( pCol->GetId() && Abs( nR - rEvtPos.X() ) < 2 )
+ {
+ // start resizing the column
+ bResizing = TRUE;
+ nResizeCol = nCol;
+ nDragX = nResizeX = rEvtPos.X();
+ SetPointer( Pointer( POINTER_HSPLIT ) );
+ CaptureMouse();
+ pDataWin->DrawLine( Point( nDragX, 0 ),
+ Point( nDragX, pDataWin->GetSizePixel().Height() ) );
+ nMinResizeX = nX + MIN_COLUMNWIDTH;
+ return;
+ }
+ else if ( nX < rEvtPos.X() && nR > rEvtPos.X() )
+ {
+ MouseButtonDown( BrowserMouseEvent(
+ this, rEvt, -1, nCol, pCol->GetId(), Rectangle() ) );
+ return;
+ }
+ nX = nR + 1;
+ }
+ }
+
+ // event occured out of data area
+ if ( rEvt.IsRight() )
+ pDataWin->Command(
+ CommandEvent( Point( 1, LONG_MAX ), COMMAND_CONTEXTMENU, TRUE ) );
+ else
+ SetNoSelection();
+}
+
+#pragma optimize("",on)
+
+//-------------------------------------------------------------------
+
+void BrowseBox::MouseMove( const MouseEvent& rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ Pointer aNewPointer;
+
+ USHORT nX = 0;
+ for ( USHORT nCol = 0;
+ nCol < USHORT(pCols->Count()) &&
+ ( nX + pCols->GetObject(nCol)->Width() ) < USHORT(GetOutputSizePixel().Width());
+ ++nCol )
+ // is this column visible?
+ if ( pCols->GetObject(nCol)->IsFrozen() || nCol >= nFirstCol )
+ {
+ // compute right end of column
+ BrowserColumn *pCol = pCols->GetObject(nCol);
+ USHORT nR = (USHORT)(nX + pCol->Width() - 1);
+
+ // show resize-pointer?
+ if ( bResizing || ( pCol->GetId() &&
+ Abs( ((long) nR ) - rEvt.GetPosPixel().X() ) < MIN_COLUMNWIDTH ) )
+ {
+ aNewPointer = Pointer( POINTER_HSPLIT );
+ if ( bResizing )
+ {
+ // alte Hilfslinie loeschen
+ pDataWin->HideTracking() ;
+
+ // erlaubte breite abholen und neues Delta
+ nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX );
+ long nDeltaX = nDragX - nResizeX;
+ USHORT nId = GetColumnId(nResizeCol);
+ ULONG nOldWidth = GetColumnWidth(nId);
+ nDragX = QueryColumnResize( GetColumnId(nResizeCol),
+ nOldWidth + nDeltaX )
+ + nResizeX - nOldWidth;
+
+ // neue Hilfslinie zeichnen
+ pDataWin->ShowTracking( Rectangle( Point( nDragX, 0 ),
+ Size( 1, pDataWin->GetSizePixel().Height() ) ),
+ SHOWTRACK_SPLIT|SHOWTRACK_WINDOW );
+ }
+
+ }
+
+ nX = nR + 1;
+ }
+
+ SetPointer( aNewPointer );
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::MouseButtonUp( const MouseEvent & rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ if ( bResizing )
+ {
+ // Hilfslinie loeschen
+ pDataWin->HideTracking();
+
+ // width changed?
+ nDragX = Max( rEvt.GetPosPixel().X(), nMinResizeX );
+ if ( (nDragX - nResizeX) != (long)pCols->GetObject(nResizeCol)->Width() )
+ {
+ // resize column
+ long nMaxX = pDataWin->GetSizePixel().Width();
+ nDragX = Min( nDragX, nMaxX );
+ long nDeltaX = nDragX - nResizeX;
+ USHORT nId = GetColumnId(nResizeCol);
+ SetColumnWidth( GetColumnId(nResizeCol), GetColumnWidth(nId) + nDeltaX );
+ ColumnResized( nId );
+ }
+
+ // end action
+ SetPointer( Pointer() );
+ ReleaseMouse();
+ bResizing = FALSE;
+ }
+ else
+ MouseButtonUp( BrowserMouseEvent( (BrowserDataWin*)pDataWin,
+ MouseEvent( Point( rEvt.GetPosPixel().X(),
+ rEvt.GetPosPixel().Y() - pDataWin->GetPosPixel().Y() ),
+ rEvt.GetClicks(), rEvt.GetMode(), rEvt.GetButtons(),
+ rEvt.GetModifier() ) ) );
+}
+
+//-------------------------------------------------------------------
+
+BOOL bExtendedMode = FALSE;
+BOOL bFieldMode = FALSE;
+
+void BrowseBox::MouseButtonDown( const BrowserMouseEvent& rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ GrabFocus();
+
+ // adjust selection while and after double-click
+ if ( rEvt.GetClicks() == 2 )
+ {
+ SetNoSelection();
+ if ( rEvt.GetRow() >= 0 )
+ {
+ GoToRow( rEvt.GetRow() );
+ SelectRow( rEvt.GetRow(), TRUE, FALSE );
+ }
+ else if ( bColumnCursor && rEvt.GetColumn() != 0 )
+ SelectColumnPos( rEvt.GetColumn(), TRUE, FALSE);
+ DoubleClick( rEvt );
+ }
+ // selections
+ else if ( ( rEvt.GetMode() & ( MOUSE_SELECT | MOUSE_SIMPLECLICK ) ) &&
+ ( bColumnCursor || rEvt.GetRow() >= 0 ) )
+ {
+ if ( rEvt.GetClicks() == 1 )
+ {
+ // initialise flags
+ bDrag = FALSE;
+ bHit = FALSE;
+ bRubber = FALSE;
+ a1stPoint =
+ a2ndPoint = PixelToLogic( rEvt.GetPosPixel() );
+
+ // selection out of range?
+ if ( rEvt.GetRow() >= nRowCount ||
+ rEvt.GetColumnId() == BROWSER_INVALIDID )
+ {
+ SetNoSelection();
+ return;
+ }
+
+ // while selecting, no cursor
+ bSelecting = TRUE;
+ DoHideCursor( "MouseButtonDown" );
+
+ // DataRow?
+ if ( rEvt.GetRow() >= 0 )
+ {
+ // Zeilenselektion?
+ if ( rEvt.GetColumnId() == 0 || !bColumnCursor )
+ {
+ if ( bMultiSelection )
+ {
+ // remove column-selection, if exists
+ if ( pColSel && pColSel->GetSelectCount() )
+ {
+ ToggleSelection();
+ if ( bMultiSelection )
+ uRow.pSel->SelectAll(FALSE);
+ else
+ uRow.nSel = BROWSER_ENDOFSELECTION;
+ if ( pColSel )
+ pColSel->SelectAll(FALSE);
+ bSelect = TRUE;
+ }
+
+ // expanding mode?
+ if ( rEvt.GetMode() & MOUSE_RANGESELECT )
+ {
+ // select the further touched rows too
+ bSelect = TRUE;
+ ExpandRowSelection( rEvt );
+ return;
+ }
+
+ // click in the selected area?
+ else if ( IsRowSelected( rEvt.GetRow() ) )
+ {
+ // auf Drag&Drop warten
+ bHit = TRUE;
+ bExtendedMode = MOUSE_MULTISELECT ==
+ ( rEvt.GetMode() & MOUSE_MULTISELECT );
+ return;
+ }
+
+ // extension mode?
+ else if ( rEvt.GetMode() & MOUSE_MULTISELECT )
+ {
+ // determine the new selection range
+ // and selection/deselection
+ aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
+ SelectRow( rEvt.GetRow(),
+ !uRow.pSel->IsSelected( rEvt.GetRow() ) );
+ bSelect = TRUE;
+ return;
+ }
+ }
+
+ // select directly
+ SetNoSelection();
+ GoToRow( rEvt.GetRow() );
+ SelectRow( rEvt.GetRow(), TRUE );
+ aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
+ bSelect = TRUE;
+ }
+ else // Column/Field-Selection
+ {
+ // click in selected column
+ if ( IsColumnSelected( rEvt.GetColumn() ) ||
+ IsRowSelected( rEvt.GetRow() ) )
+ {
+ bHit = TRUE;
+ bFieldMode = TRUE;
+ return;
+ }
+
+ SetNoSelection();
+ GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
+ bSelect = TRUE;
+ }
+ }
+ else
+ {
+ if ( bMultiSelection && rEvt.GetColumnId() == 0 )
+ {
+ // toggle all-selection
+ if ( uRow.pSel->GetSelectCount() > ( GetRowCount() / 2 ) )
+ SetNoSelection();
+ else
+ SelectAll();
+ }
+ else
+ SelectColumnId( rEvt.GetColumnId(), TRUE, FALSE );
+ }
+
+ // ggf. Cursor wieder an
+ bSelecting = FALSE;
+ DoShowCursor( "MouseButtonDown" );
+ if ( bSelect )
+ Select();
+ }
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::MouseMove( const BrowserMouseEvent &rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::MouseButtonUp( const BrowserMouseEvent &rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ // D&D was possible, but did not occur
+ if ( bHit )
+ {
+ aSelRange = Range( rEvt.GetRow(), rEvt.GetRow() );
+ if ( bExtendedMode )
+ SelectRow( rEvt.GetRow(), FALSE );
+ else
+ {
+ SetNoSelection();
+ if ( bFieldMode )
+ GoToRowColumnId( rEvt.GetRow(), rEvt.GetColumnId() );
+ else
+ {
+ GoToRow( rEvt.GetRow() );
+ SelectRow( rEvt.GetRow(), TRUE );
+ }
+ }
+ bSelect = TRUE;
+ bExtendedMode = FALSE;
+ bFieldMode = FALSE;
+ bHit = FALSE;
+ }
+
+ // activate cursor
+ if ( bSelecting )
+ {
+ bSelecting = FALSE;
+ DoShowCursor( "MouseButtonUp" );
+ if ( bSelect )
+ Select();
+ }
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::Drop( const BrowserDropEvent& )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return FALSE;
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::QueryDrop( const BrowserDropEvent& )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ return FALSE;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::KeyInput( const KeyEvent& rEvt )
+{
+ if ( !ProcessKey( rEvt ) )
+ Control::KeyInput( rEvt );
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowseBox::ProcessKey( const KeyEvent& rEvt )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ USHORT nCode = rEvt.GetKeyCode().GetCode();
+ BOOL bShift = rEvt.GetKeyCode().IsShift();
+ BOOL bCtrl = rEvt.GetKeyCode().IsMod1();
+ BOOL bAlt = rEvt.GetKeyCode().IsMod2();
+
+ USHORT nId = BROWSER_NONE;
+
+ if ( !bAlt && !bCtrl && !bShift )
+ {
+ switch ( nCode )
+ {
+ case KEY_DOWN: nId = BROWSER_CURSORDOWN; break;
+ case KEY_UP: nId = BROWSER_CURSORUP; break;
+ case KEY_HOME: nId = BROWSER_CURSORHOME; break;
+ case KEY_END: nId = BROWSER_CURSOREND; break;
+ case KEY_TAB:
+ if ( !bColumnCursor )
+ break;
+ case KEY_RIGHT: nId = BROWSER_CURSORRIGHT; break;
+ case KEY_LEFT: nId = BROWSER_CURSORLEFT; break;
+ case KEY_SPACE: nId = BROWSER_SELECT; break;
+ }
+ if ( BROWSER_NONE != nId )
+ SetNoSelection();
+
+ switch ( nCode )
+ {
+ case KEY_PAGEDOWN: nId = BROWSER_CURSORPAGEDOWN; break;
+ case KEY_PAGEUP: nId = BROWSER_CURSORPAGEUP; break;
+ }
+ }
+
+ if ( !bAlt && !bCtrl && bShift )
+ switch ( nCode )
+ {
+ case KEY_DOWN: nId = BROWSER_SELECTDOWN; break;
+ case KEY_UP: nId = BROWSER_SELECTUP; break;
+ case KEY_TAB:
+ if ( !bColumnCursor )
+ break;
+ nId = BROWSER_CURSORLEFT; break;
+ case KEY_HOME: nId = BROWSER_SELECTHOME; break;
+ case KEY_END: nId = BROWSER_SELECTEND; break;
+ }
+
+
+ if ( !bAlt && bCtrl && !bShift )
+ switch ( nCode )
+ {
+ case KEY_DOWN: nId = BROWSER_CURSORDOWN; break;
+ case KEY_UP: nId = BROWSER_CURSORUP; break;
+ case KEY_PAGEDOWN: nId = BROWSER_CURSORENDOFFILE; break;
+ case KEY_PAGEUP: nId = BROWSER_CURSORTOPOFFILE; break;
+ case KEY_HOME: nId = BROWSER_CURSORTOPOFSCREEN; break;
+ case KEY_END: nId = BROWSER_CURSORENDOFSCREEN; break;
+ case KEY_SPACE: nId = BROWSER_ENHANCESELECTION; break;
+ }
+
+ if ( nId != BROWSER_NONE )
+ Dispatch( nId );
+ return nId != BROWSER_NONE;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::Dispatch( USHORT nId )
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+
+ long nRowsOnPage = pDataWin->GetSizePixel().Height() / GetDataRowHeight();
+ BOOL bDone = FALSE;
+
+ switch ( nId )
+ {
+ case BROWSER_CURSORDOWN:
+ if ( ( GetCurRow() + 1 ) < nRowCount )
+ bDone = GoToRow( GetCurRow() + 1, FALSE );
+ break;
+ case BROWSER_CURSORUP:
+ if ( GetCurRow() > 0 )
+ bDone = GoToRow( GetCurRow() - 1, FALSE );
+ break;
+ case BROWSER_SELECTHOME:
+ {
+ DoHideCursor( "BROWSER_SELECTHOME" );
+ for ( long nRow = GetCurRow(); nRow >= 0; --nRow )
+ SelectRow( nRow );
+ GoToRow( 0, TRUE );
+ DoShowCursor( "BROWSER_SELECTHOME" );
+ break;
+ }
+ case BROWSER_SELECTEND:
+ {
+ DoHideCursor( "BROWSER_SELECTEND" );
+ long nRowCount = GetRowCount();
+ for ( long nRow = GetCurRow(); nRow < nRowCount; ++nRow )
+ SelectRow( nRow );
+ GoToRow( GetRowCount() - 1, TRUE );
+ DoShowCursor( "BROWSER_SELECTEND" );
+ break;
+ }
+ case BROWSER_SELECTDOWN:
+ {
+ if ( ( GetCurRow() + 1 ) < nRowCount )
+ {
+ // deselect the current row, if it isn't the first
+ // and there is no other selected row above
+ long nCurRow = GetCurRow();
+ BOOL bSelect = ( !IsRowSelected( nCurRow ) ||
+ GetSelectRowCount() == 1 || IsRowSelected( nCurRow - 1 ) );
+ SelectRow( nCurRow, bSelect, TRUE );
+ if ( bDone = GoToRow( GetCurRow() + 1 , FALSE ) )
+ SelectRow( GetCurRow(), TRUE, TRUE );
+ }
+ else
+ bDone = ScrollRows( 1 ) != 0;
+ break;
+ }
+ case BROWSER_SELECTUP:
+ {
+ // deselect the current row, if it isn't the first
+ // and there is no other selected row under
+ long nCurRow = GetCurRow();
+ BOOL bSelect = ( !IsRowSelected( nCurRow ) ||
+ GetSelectRowCount() == 1 || IsRowSelected( nCurRow + 1 ) );
+ SelectRow( nCurRow, bSelect, TRUE );
+ if ( bDone = GoToRow( nCurRow - 1 , FALSE ) )
+ SelectRow( GetCurRow(), TRUE, TRUE );
+ break;
+ }
+ case BROWSER_CURSORPAGEDOWN:
+ bDone = (BOOL)ScrollRows( nRowsOnPage );
+ break;
+ case BROWSER_CURSORPAGEUP:
+ bDone = (BOOL)ScrollRows( -nRowsOnPage );
+ break;
+ case BROWSER_CURSOREND:
+ if ( bColumnCursor )
+ {
+ USHORT nNewId = GetColumnId(ColCount() -1);
+ bDone = (nNewId != 0) && GoToColumnId( nNewId );
+ break;
+ }
+ case BROWSER_CURSORENDOFFILE:
+ bDone = GoToRow( nRowCount - 1, FALSE );
+ break;
+ case BROWSER_CURSORRIGHT:
+ if ( bColumnCursor )
+ {
+ USHORT nNewPos = GetColumnPos( GetCurColumnId() ) + 1;
+ USHORT nNewId = GetColumnId( nNewPos );
+ if (nNewId != 0) // Am Zeilenende ?
+ bDone = GoToColumnId( nNewId );
+ else
+ {
+ USHORT nColId = ( GetColumnId(0) == 0 ) ? GetColumnId(1) : GetColumnId(0);
+ bDone = ( nCurRow < GetRowCount() - 1 ) && GoToRowColumnId( nCurRow + 1, nColId );
+ }
+ }
+ else
+ bDone = ScrollColumns( 1 ) != 0;
+ break;
+ case BROWSER_CURSORHOME:
+ if ( bColumnCursor )
+ {
+ USHORT nNewId = GetColumnId(1);
+ bDone = (nNewId != 0) && GoToColumnId( nNewId );
+ break;
+ }
+ case BROWSER_CURSORTOPOFFILE:
+ bDone = GoToRow( 0, FALSE );
+ break;
+ case BROWSER_CURSORLEFT:
+ if ( bColumnCursor )
+ {
+ USHORT nNewPos = GetColumnPos( GetCurColumnId() ) - 1;
+ USHORT nNewId = GetColumnId( nNewPos );
+ if (nNewId != 0)
+ bDone = GoToColumnId( nNewId );
+ else
+ bDone = (nCurRow > 0) && GoToRowColumnId(nCurRow - 1, GetColumnId(ColCount() -1));
+ }
+ else
+ bDone = ScrollColumns( -1 ) != 0;
+ break;
+ case BROWSER_ENHANCESELECTION:
+ SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), TRUE );
+ bDone = TRUE;
+ break;
+ case BROWSER_SELECT:
+ SelectRow( GetCurRow(), !IsRowSelected( GetCurRow() ), FALSE );
+ bDone = TRUE;
+ break;
+ }
+
+ //! return bDone;
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::LoseFocus()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ DBG_TRACE1( "BrowseBox: %p->LoseFocus", this );
+
+ if ( bHasFocus )
+ {
+ DBG_TRACE1( "BrowseBox: %p->HideCursor", this );
+ DoHideCursor( "LoseFocus" );
+
+ if ( !bKeepHighlight )
+ {
+ ToggleSelection();
+ bSelectionIsVisible = FALSE;
+ }
+
+ bHasFocus = FALSE;
+ }
+ Control::LoseFocus();
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::GetFocus()
+{
+ DBG_CHKTHIS(BrowseBox,BrowseBoxCheckInvariants);
+ DBG_TRACE1( "BrowseBox: %p->GetFocus", this );
+
+ if ( !bHasFocus )
+ {
+ if ( !bSelectionIsVisible )
+ {
+ bSelectionIsVisible = TRUE;
+ if ( bBootstrapped )
+ ToggleSelection();
+ }
+
+ bHasFocus = TRUE;
+ DoShowCursor( "GetFocus" );
+ }
+ Control::GetFocus();
+}
+
+//-------------------------------------------------------------------
+
+void BrowseBox::SetCursorColor(const Color& _rCol)
+{
+ if (_rCol == m_aCursorColor)
+ return;
+
+ // ensure the cursor is hidden
+ DoHideCursor("SetCursorColor");
+ if (!m_bFocusOnlyCursor)
+ DoHideCursor("SetCursorColor - force");
+
+ m_aCursorColor = _rCol;
+
+ if (!m_bFocusOnlyCursor)
+ DoShowCursor("SetCursorColor - force");
+ DoShowCursor("SetCursorColor");
+}
+
+
diff --git a/svtools/source/brwbox/brwhead.cxx b/svtools/source/brwbox/brwhead.cxx
new file mode 100644
index 000000000000..f38be0045746
--- /dev/null
+++ b/svtools/source/brwbox/brwhead.cxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * $RCSfile: brwhead.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "brwhead.hxx"
+#include "brwbox.hxx"
+
+#pragma hdrstop
+
+//===================================================================
+
+BrowserHeader::BrowserHeader( BrowseBox* pParent, WinBits nWinBits )
+: HeaderBar( pParent, nWinBits ),
+ _pBrowseBox( pParent )
+{
+ long nHeight = pParent->IsZoom() ? pParent->CalcZoom(nHeight) : pParent->GetTitleHeight();
+
+ SetPosSizePixel( Point( 0, 0),
+ Size( pParent->GetOutputSizePixel().Width(),
+ nHeight ) );
+ Show();
+}
+
+//-------------------------------------------------------------------
+
+void BrowserHeader::Command( const CommandEvent& rCEvt )
+{
+ if ( !GetCurItemId() && COMMAND_CONTEXTMENU == rCEvt.GetCommand() )
+ {
+ Point aPos( rCEvt.GetMousePosPixel() );
+ _pBrowseBox->GetDataWindow().Command( CommandEvent(
+ Point( aPos.X(), aPos.Y() - GetSizePixel().Height() ),
+ COMMAND_CONTEXTMENU, rCEvt.IsMouseEvent() ) );
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowserHeader::Select()
+{
+ HeaderBar::Select();
+}
+
+//-------------------------------------------------------------------
+
+void BrowserHeader::EndDrag()
+{
+ // call before other actions, it looks more nice in most cases
+ HeaderBar::EndDrag();
+ Update();
+
+ // not aborted?
+ USHORT nId = GetCurItemId();
+ if ( nId )
+ {
+ // Handle-Column?
+ if ( nId == USHRT_MAX-1 )
+ nId = 0;
+
+ if ( !IsItemMode() )
+ {
+ // column resize
+ _pBrowseBox->SetColumnWidth( nId, GetItemSize( nId ) );
+ _pBrowseBox->ColumnResized( nId );
+ SetItemSize( nId, _pBrowseBox->GetColumnWidth( nId ) );
+ }
+ else
+ {
+ // column drag
+ // Hat sich die Position eigentlich veraendert
+ // Handlecolumn beruecksichtigen
+ USHORT nOldPos = _pBrowseBox->GetColumnPos(nId),
+ nNewPos = GetItemPos( nId );
+
+ if (!_pBrowseBox->GetColumnId(0)) // Handle
+ nNewPos++;
+
+ if (nOldPos != nNewPos)
+ {
+ _pBrowseBox->SetColumnPos( nId, nNewPos );
+ _pBrowseBox->ColumnMoved( nId );
+ }
+ }
+ }
+}
+
+
diff --git a/svtools/source/brwbox/datwin.cxx b/svtools/source/brwbox/datwin.cxx
new file mode 100644
index 000000000000..3bf03276acf7
--- /dev/null
+++ b/svtools/source/brwbox/datwin.cxx
@@ -0,0 +1,694 @@
+/*************************************************************************
+ *
+ * $RCSfile: datwin.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include "datwin.hxx"
+
+#pragma hdrstop
+
+#ifndef _APP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef _IMAGE_HXX
+#include <vcl/image.hxx>
+#endif
+
+#include <tools/debug.hxx>
+
+DECLARE_LIST( BrowserColumns, BrowserColumn* );
+
+//===================================================================
+
+static String FitInWidth( OutputDevice& rWin, String aVal, ULONG nWidth, BOOL bAbbr )
+{
+ if ( nWidth < 8 )
+ return String();
+ ULONG nValWidth = rWin.GetTextWidth( aVal );
+ if ( nValWidth > nWidth )
+ {
+ String aDots( "...", RTL_TEXTENCODING_IBM_850 );
+ ULONG nDotsWidth = 2;
+ if ( bAbbr )
+ nDotsWidth = rWin.GetTextWidth( aDots );
+ if ( nDotsWidth > nWidth )
+ aVal.Erase();
+ else
+ {
+ aVal.Erase( aVal.Len() - 1 );
+ while ( aVal.Len() && rWin.GetTextWidth( aVal ) + nDotsWidth > nWidth )
+ aVal.Erase( aVal.Len() - 1 );
+ if ( bAbbr )
+ aVal += aDots;
+ }
+ }
+
+ return aVal;
+}
+
+//-------------------------------------------------------------------
+
+void ButtonFrame::Draw( OutputDevice& rDev )
+{
+ Color aOldFillColor = rDev.GetFillColor();
+ Color aOldLineColor = rDev.GetLineColor();
+
+ const StyleSettings &rSettings = rDev.GetSettings().GetStyleSettings();
+ Color aColLight( rSettings.GetLightColor() );
+ Color aColShadow( rSettings.GetShadowColor() );
+ Color aColFace( rSettings.GetFaceColor() );
+
+ rDev.SetLineColor( bPressed ? aColShadow : aColLight );
+ rDev.DrawLine( aRect.TopLeft(), Point( aRect.Right(), aRect.Top() ) );
+ rDev.DrawLine( aRect.TopLeft(), Point( aRect.Left(), aRect.Bottom() - 1 ) );
+ rDev.SetLineColor( bPressed ? aColLight : aColShadow );
+ rDev.DrawLine( aRect.BottomRight(), Point( aRect.Right(), aRect.Top() ) );
+ rDev.DrawLine( aRect.BottomRight(), Point( aRect.Left(), aRect.Bottom() ) );
+
+ rDev.SetLineColor( aColFace );
+ rDev.SetFillColor( aColFace );
+ rDev.DrawRect( aInnerRect );
+
+ if ( aText.Len() )
+ {
+ String aVal( FitInWidth( rDev, aText, aInnerRect.GetWidth() - 2*MIN_COLUMNWIDTH, bAbbr ) );
+ Font aFont( rDev.GetFont() );
+ BOOL bOldTransp = aFont.IsTransparent();
+ if ( !bOldTransp )
+ {
+ aFont.SetTransparent( TRUE );
+ rDev.SetFont( aFont );
+ }
+
+ rDev.DrawText( Point(
+ ( aInnerRect.Left() + aInnerRect.Right() ) / 2 - ( rDev.GetTextWidth(aVal) / 2 ),
+ aInnerRect.Top() ), aVal );
+
+ if ( !bOldTransp )
+ {
+ aFont.SetTransparent(FALSE);
+ rDev.SetFont( aFont );
+ }
+ }
+
+ if ( bCurs )
+ {
+ rDev.SetLineColor( Color( COL_BLACK ) );
+ rDev.SetFillColor();
+ rDev.DrawRect( Rectangle(
+ Point( aRect.Left(), aRect.Top() ), Point( aRect.Right(), aRect.Bottom() ) ) );
+ }
+
+ rDev.SetLineColor( aOldLineColor );
+ rDev.SetFillColor( aOldFillColor );
+}
+
+//-------------------------------------------------------------------
+
+BrowserColumn::BrowserColumn( USHORT nItemId, const class Image &rImage,
+ const String& rTitle, ULONG nWidthPixel, const Fraction& rCurrentZoom,
+ HeaderBarItemBits nFlags )
+: _nId( nItemId ),
+ _nWidth( nWidthPixel ),
+ _aImage( rImage ),
+ _aTitle( rTitle ),
+ _bFrozen( FALSE ),
+ _nFlags( nFlags )
+{
+ double n = (double)_nWidth;
+ n *= (double)rCurrentZoom.GetDenominator();
+ n /= (double)rCurrentZoom.GetNumerator();
+ _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
+}
+
+//-------------------------------------------------------------------
+
+void BrowserColumn::SetWidth(ULONG nNewWidthPixel, const Fraction& rCurrentZoom)
+{
+ _nWidth = nNewWidthPixel;
+ double n = (double)_nWidth;
+ n *= (double)rCurrentZoom.GetDenominator();
+ n /= (double)rCurrentZoom.GetNumerator();
+ _nOriginalWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
+}
+
+//-------------------------------------------------------------------
+
+void BrowserColumn::Draw( BrowseBox& rBox, OutputDevice& rDev, const Point& rPos, BOOL bCurs )
+{
+ if ( _nId == 0 )
+ {
+ // paint handle column
+ ButtonFrame( rPos, Size( Width()-1, rBox.GetDataRowHeight()-1 ),
+ String(), FALSE, bCurs,
+ 0 != (BROWSER_COLUMN_TITLEABBREVATION&_nFlags) ).Draw( rDev );
+ Color aOldLineColor = rDev.GetLineColor();
+ rDev.SetLineColor( Color( COL_BLACK ) );
+ rDev.DrawLine(
+ Point( rPos.X(), rPos.Y()+rBox.GetDataRowHeight()-1 ),
+ Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
+ rDev.DrawLine(
+ Point( rPos.X() + Width() - 1, rPos.Y() ),
+ Point( rPos.X() + Width() - 1, rPos.Y()+rBox.GetDataRowHeight()-1 ) );
+ rDev.SetLineColor( aOldLineColor );
+
+ if ( rBox.bHasBitmapHandle )
+ rBox.PaintField( rDev,
+ Rectangle(
+ Point( rPos.X() + 2, rPos.Y() + 2 ),
+ Size( Width()-1, rBox.GetDataRowHeight()-1 ) ),
+ GetId() );
+ }
+ else
+ {
+ // paint data column
+ long nWidth = Width() == LONG_MAX ? rBox.GetDataWindow().GetSizePixel().Width() : Width();
+
+ rBox.PaintField( rDev,
+ Rectangle(
+ Point( rPos.X() + MIN_COLUMNWIDTH, rPos.Y() ),
+ Size( nWidth-2*MIN_COLUMNWIDTH, rBox.GetDataRowHeight()-1 ) ),
+ GetId() );
+ }
+}
+
+//-------------------------------------------------------------------
+
+void BrowserColumn::ZoomChanged(const Fraction& rNewZoom)
+{
+ double n = (double)_nOriginalWidth;
+ n *= (double)rNewZoom.GetNumerator();
+ n /= (double)rNewZoom.GetDenominator();
+
+ _nWidth = n>0 ? (long)(n+0.5) : -(long)(-n+0.5);
+}
+
+//-------------------------------------------------------------------
+
+BrowserDataWin::BrowserDataWin( BrowseBox* pParent ) :
+ Control( pParent, WinBits(WB_CLIPCHILDREN) ),
+ pHeaderBar( 0 ),
+ pEventWin( pParent ),
+ pCornerWin( 0 ),
+ bInPaint( FALSE ),
+ bInCommand( FALSE ),
+ bNoScrollBack( FALSE ),
+ bUpdateMode( TRUE ),
+ bResizeOnPaint( FALSE ),
+ bUpdateOnUnlock( FALSE ),
+ bInUpdateScrollbars( FALSE ),
+ bHadRecursion( FALSE ),
+ bOwnDataChangedHdl( FALSE ),
+ nUpdateLock( 0 ),
+ nCursorHidden( 0 ),
+ pDtorNotify( 0 )
+{
+ aMouseTimer.SetTimeoutHdl( LINK( this, BrowserDataWin, RepeatedMouseMove ) );
+ aMouseTimer.SetTimeout( 100 );
+}
+
+//-------------------------------------------------------------------
+BrowserDataWin::~BrowserDataWin()
+{
+ if( pDtorNotify )
+ *pDtorNotify = TRUE;
+ if ( IsMouseCaptured() )
+ ReleaseMouse();
+}
+
+//-------------------------------------------------------------------
+void BrowserDataWin::LeaveUpdateLock()
+{
+ if ( !--nUpdateLock )
+ {
+ DoOutstandingInvalidations();
+ if (bUpdateOnUnlock )
+ {
+ Control::Update();
+ bUpdateOnUnlock = FALSE;
+ }
+ }
+}
+
+//-------------------------------------------------------------------
+void InitSettings_Impl( Window *pWin,
+ BOOL bFont, BOOL bForeground, BOOL bBackground )
+{
+ const StyleSettings& rStyleSettings =
+ pWin->GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( pWin->IsControlFont() )
+ aFont.Merge( pWin->GetControlFont() );
+ pWin->SetPointFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetWindowTextColor();
+ if ( pWin->IsControlForeground() )
+ aTextColor = pWin->GetControlForeground();
+ pWin->SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ if( pWin->IsControlBackground() )
+ pWin->SetBackground( pWin->GetControlBackground() );
+ else
+ pWin->SetBackground( rStyleSettings.GetWindowColor() );
+ }
+}
+
+//-------------------------------------------------------------------
+void BrowserDataWin::Update()
+{
+ if ( !nUpdateLock )
+ Control::Update();
+ else
+ bUpdateOnUnlock = TRUE;
+}
+
+//-------------------------------------------------------------------
+void BrowserDataWin::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ if( !bOwnDataChangedHdl )
+ {
+ InitSettings_Impl( this, TRUE, TRUE, TRUE );
+ Invalidate();
+ InitSettings_Impl( GetParent(), TRUE, TRUE, TRUE );
+ GetParent()->Invalidate();
+ }
+ }
+ else
+ Control::DataChanged( rDCEvt );
+}
+
+//-------------------------------------------------------------------
+void BrowserDataWin::Paint( const Rectangle& rRect )
+{
+ if ( !nUpdateLock && GetUpdateMode() )
+ {
+ bInPaint = TRUE;
+ ( (BrowseBox*) GetParent() )->PaintData( *this, rRect );
+ bInPaint = FALSE;
+ }
+ else
+ aInvalidRegion.Insert( new Rectangle( rRect ) );
+}
+
+//-------------------------------------------------------------------
+
+BrowseEvent BrowserDataWin::CreateBrowseEvent( const Point& rPosPixel )
+{
+ BrowseBox *pBox = GetParent();
+
+ // seek to row under mouse
+ short nRelRow = rPosPixel.Y() < 0
+ ? -1
+ : rPosPixel.Y() / pBox->GetDataRowHeight();
+ long nRow = nRelRow < 0 ? -1 : nRelRow + pBox->nTopRow;
+
+ // find column under mouse
+ long nMouseX = rPosPixel.X();
+ long nColX = 0;
+ USHORT nCol;
+ for ( nCol = 0;
+ nCol < pBox->pCols->Count() && nColX < GetSizePixel().Width();
+ ++nCol )
+ if ( pBox->pCols->GetObject(nCol)->IsFrozen() || nCol >= pBox->nFirstCol )
+ {
+ nColX += pBox->pCols->GetObject(nCol)->Width();
+ if ( nMouseX < nColX )
+ break;
+ }
+ USHORT nColId = BROWSER_INVALIDID;
+ if ( nCol < pBox->pCols->Count() )
+ nColId = pBox->pCols->GetObject(nCol)->GetId();
+
+ // compute the field rectangle and field relative MouseEvent
+ Rectangle aFieldRect;
+ MouseEvent aRelEvt;
+ if ( nCol < pBox->pCols->Count() )
+ {
+ nColX -= pBox->pCols->GetObject(nCol)->Width();
+ aFieldRect = Rectangle(
+ Point( nColX, nRelRow * pBox->GetDataRowHeight() ),
+ Size( pBox->pCols->GetObject(nCol)->Width(),
+ pBox->GetDataRowHeight() ) );
+ }
+
+ // assemble and return the BrowseEvent
+ return BrowseEvent( this, nRow, nCol, nColId, aFieldRect );
+}
+
+//-------------------------------------------------------------------
+void BrowserDataWin::Command( const CommandEvent& rEvt )
+{
+ // Scrollmaus-Event?
+ BrowseBox *pBox = GetParent();
+ if ( ( (rEvt.GetCommand() == COMMAND_WHEEL) ||
+ (rEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
+ (rEvt.GetCommand() == COMMAND_AUTOSCROLL) ) &&
+ ( HandleScrollCommand( rEvt, &pBox->aHScroll, pBox->pVScroll ) ) )
+ return;
+
+ Point aEventPos( rEvt.GetMousePosPixel() );
+ long nRow = pBox->GetRowAtYPosPixel( aEventPos.Y(), FALSE);
+ MouseEvent aMouseEvt( aEventPos, 1, MOUSE_SELECT, MOUSE_LEFT );
+ if ( COMMAND_CONTEXTMENU == rEvt.GetCommand() && rEvt.IsMouseEvent() &&
+ nRow < pBox->GetRowCount() && !pBox->IsRowSelected(nRow) )
+ {
+ BOOL bDeleted = FALSE;
+ pDtorNotify = &bDeleted;
+ bInCommand = TRUE;
+ MouseButtonDown( aMouseEvt );
+ if( bDeleted )
+ return;
+ MouseButtonUp( aMouseEvt );
+ if( bDeleted )
+ return;
+ pDtorNotify = 0;
+ bInCommand = FALSE;
+ }
+
+ aEventPos.Y() += GetParent()->GetTitleHeight();
+ CommandEvent aEvt( aEventPos, rEvt.GetCommand(),
+ rEvt.IsMouseEvent(), rEvt.GetData() );
+ bInCommand = TRUE;
+ BOOL bDeleted = FALSE;
+ pDtorNotify = &bDeleted;
+ GetParent()->Command( aEvt );
+ if( bDeleted )
+ return;
+ pDtorNotify = 0;
+ bInCommand = FALSE;
+
+ if ( COMMAND_STARTDRAG == rEvt.GetCommand() )
+ MouseButtonUp( aMouseEvt );
+
+ Control::Command( rEvt );
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::MouseButtonDown( const MouseEvent& rEvt )
+{
+ aLastMousePos = OutputToScreenPixel( rEvt.GetPosPixel() );
+ CaptureMouse();
+ GetParent()->MouseButtonDown( BrowserMouseEvent( this, rEvt ) );
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::MouseMove( const MouseEvent& rEvt )
+{
+ // Pseudo MouseMoves verhindern
+ Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
+ if ( aNewPos == aLastMousePos )
+ return;
+ aLastMousePos = aNewPos;
+
+ // Paint-Probleme abfangen
+ if ( !IsMouseCaptured() )
+ return;
+
+ // transform to a BrowseEvent
+ GetParent()->MouseMove( BrowserMouseEvent( this, rEvt ) );
+
+ // dragging out of the visible area?
+ if ( rEvt.IsLeft() &&
+ ( rEvt.GetPosPixel().Y() > GetSizePixel().Height() ||
+ rEvt.GetPosPixel().Y() < 0 ) )
+ {
+ // repeat the event
+ aRepeatEvt = rEvt;
+ aMouseTimer.Start();
+ }
+ else
+ // killing old repeat-event
+ if ( aMouseTimer.IsActive() )
+ aMouseTimer.Stop();
+}
+
+//-------------------------------------------------------------------
+
+IMPL_LINK_INLINE_START( BrowserDataWin, RepeatedMouseMove, void *, pvoid )
+{
+ GetParent()->MouseMove( BrowserMouseEvent( this, aRepeatEvt ) );
+ return 0;
+}
+IMPL_LINK_INLINE_END( BrowserDataWin, RepeatedMouseMove, void *, pvoid )
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::MouseButtonUp( const MouseEvent& rEvt )
+{
+ // Pseudo MouseMoves verhindern
+ Point aNewPos = OutputToScreenPixel( rEvt.GetPosPixel() );
+ aLastMousePos = aNewPos;
+
+ // Paint-Probleme abfangen
+ if ( !IsMouseCaptured() )
+ return;
+
+ // Move an die aktuelle Position simulieren
+ MouseMove( rEvt );
+
+ // eigentliches Up-Handling
+ ReleaseMouse();
+ if ( aMouseTimer.IsActive() )
+ aMouseTimer.Stop();
+ GetParent()->MouseButtonUp( BrowserMouseEvent( this, rEvt ) );
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::KeyInput( const KeyEvent& rEvt )
+{
+ // pass to parent window
+ if ( !GetParent()->ProcessKey( rEvt ) )
+ Control::KeyInput( rEvt );
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::RequestHelp( const HelpEvent& rHEvt )
+{
+ pEventWin = this;
+ GetParent()->RequestHelp( rHEvt );
+ pEventWin = GetParent();
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowserDataWin::Drop( const DropEvent& rEvt )
+{
+ return GetParent()->Drop( BrowserDropEvent( this, rEvt ) );
+}
+
+//-------------------------------------------------------------------
+
+BOOL BrowserDataWin::QueryDrop( DropEvent& rEvt )
+{
+ BrowserDropEvent aBrwDEvt( this, rEvt );
+ BOOL bRet = GetParent()->QueryDrop( aBrwDEvt );
+ rEvt = aBrwDEvt;
+ return bRet;
+}
+
+//===================================================================
+
+BrowseEvent::BrowseEvent( Window* pWindow,
+ long nAbsRow, USHORT nColumn, USHORT nColumnId,
+ const Rectangle& rRect ):
+ pWin(pWindow),
+ nRow(nAbsRow),
+ nCol(nColumn),
+ nColId(nColumnId),
+ aRect(rRect)
+{
+}
+
+//===================================================================
+
+BrowserMouseEvent::BrowserMouseEvent( BrowserDataWin *pWin,
+ const MouseEvent& rEvt ):
+ MouseEvent(rEvt),
+ BrowseEvent( pWin->CreateBrowseEvent( rEvt.GetPosPixel() ) )
+{
+}
+
+//-------------------------------------------------------------------
+
+BrowserMouseEvent::BrowserMouseEvent( Window *pWin, const MouseEvent& rEvt,
+ long nAbsRow, USHORT nColumn, USHORT nColumnId,
+ const Rectangle& rRect ):
+ MouseEvent(rEvt),
+ BrowseEvent( pWin, nAbsRow, nColumn, nColumnId, rRect )
+{
+}
+
+//===================================================================
+
+BrowserDropEvent::BrowserDropEvent( BrowserDataWin *pWin, const DropEvent& rEvt ):
+ DropEvent(rEvt),
+ BrowseEvent( pWin->CreateBrowseEvent( rEvt.GetPosPixel() ) )
+{
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::SetUpdateMode( BOOL bMode )
+{
+ DBG_ASSERT( !bUpdateMode || aInvalidRegion.Count() == 0,
+ "invalid region not empty" );
+ if ( bMode == bUpdateMode )
+ return;
+
+ bUpdateMode = bMode;
+ if ( bMode )
+ DoOutstandingInvalidations();
+}
+
+//-------------------------------------------------------------------
+void BrowserDataWin::DoOutstandingInvalidations()
+{
+ for ( Rectangle* pRect = aInvalidRegion.First();
+ pRect;
+ pRect = aInvalidRegion.Next() )
+ {
+ Window::Invalidate( *pRect, INVALIDATE_NOCHILDREN /*OV*/);
+ delete pRect;
+ }
+ aInvalidRegion.Clear();
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::Invalidate()
+{
+ if ( !GetUpdateMode() )
+ {
+ for ( Rectangle* pRect = aInvalidRegion.First();
+ pRect;
+ pRect = aInvalidRegion.Next() )
+ delete pRect;
+ aInvalidRegion.Clear();
+ aInvalidRegion.Insert(
+ new Rectangle( Point( 0, 0 ), GetOutputSizePixel() ) );
+ }
+ else
+ Window::Invalidate(INVALIDATE_NOCHILDREN /*OV*/ );
+}
+
+//-------------------------------------------------------------------
+
+void BrowserDataWin::Invalidate( const Rectangle& rRect )
+{
+ if ( !GetUpdateMode() )
+ aInvalidRegion.Insert( new Rectangle( rRect ) );
+ else
+ Window::Invalidate( rRect, INVALIDATE_NOCHILDREN /*OV*/ );
+}
+
+//===================================================================
+
+void BrowserScrollBar::Tracking( const TrackingEvent& rTEvt )
+{
+ ULONG nPos = GetThumbPos();
+ if ( nPos != _nLastPos )
+ {
+ if ( _nTip )
+ Help::HideTip( _nTip );
+
+ String aTip( String::CreateFromInt32(nPos) );
+ aTip += '/';
+ if ( _pDataWin->GetRealRowCount().Len() )
+ aTip += _pDataWin->GetRealRowCount();
+ else
+ aTip += String::CreateFromInt32(GetRangeMax());
+ Rectangle aRect( GetPointerPosPixel(), Size( GetTextHeight(), GetTextWidth( aTip ) ) );
+ _nTip = Help::ShowTip( this, aRect, aTip );
+ _nLastPos = nPos;
+ }
+
+ ScrollBar::Tracking( rTEvt );
+}
+
+//-------------------------------------------------------------------
+
+void BrowserScrollBar::EndScroll()
+{
+ if ( _nTip )
+ Help::HideTip( _nTip );
+ _nTip = 0;
+ ScrollBar::EndScroll();
+}
+
+
diff --git a/svtools/source/brwbox/datwin.hxx b/svtools/source/brwbox/datwin.hxx
new file mode 100644
index 000000000000..3fcd002e392d
--- /dev/null
+++ b/svtools/source/brwbox/datwin.hxx
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * $RCSfile: datwin.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SFXDATWIN_HXX
+#define _SFXDATWIN_HXX
+
+#ifndef _BRWBOX_HXX
+#include <brwbox.hxx>
+#endif
+
+#ifndef _BRWHEAD_HXX
+#include <brwhead.hxx>
+#endif
+
+#ifndef _TIMER_HXX //autogen
+#include <vcl/timer.hxx>
+#endif
+#ifndef _IMAGE_HXX //autogen
+#include <vcl/image.hxx>
+#endif
+#ifndef _LIST_HXX //autogen
+#include <tools/list.hxx>
+#endif
+//===================================================================
+
+#define MIN_COLUMNWIDTH 2
+#define DRAG_CRITICAL 4
+
+DECLARE_LIST( RectangleList, Rectangle* );
+
+//===================================================================
+
+class ButtonFrame
+{
+ Rectangle aRect;
+ Rectangle aInnerRect;
+ String aText;
+ BOOL bPressed;
+ BOOL bCurs;
+ BOOL bAbbr;
+
+public:
+ ButtonFrame( const Point& rPt, const Size& rSz,
+ const String &rText,
+ BOOL bPress = FALSE, BOOL bCursor = FALSE,
+ BOOL bAbbreviate = TRUE ) :
+ aRect( rPt, rSz ),
+ aInnerRect( Point( aRect.Left()+1, aRect.Top()+1 ),
+ Size( aRect.GetWidth()-2, aRect.GetHeight()-2 ) ),
+ aText(rText),
+ bPressed(bPress),
+ bCurs(bCursor),
+ bAbbr(bAbbreviate)
+ {}
+
+ void Draw( OutputDevice& rDev );
+};
+
+//===================================================================
+
+class BrowserColumn
+{
+ USHORT _nId;
+ ULONG _nOriginalWidth;
+ ULONG _nWidth;
+ Image _aImage;
+ String _aTitle;
+ BOOL _bFrozen;
+ HeaderBarItemBits _nFlags;
+
+public:
+ BrowserColumn( USHORT nItemId, const Image &rImage,
+ const String& rTitle, ULONG nWidthPixel, const Fraction& rCurrentZoom,
+ HeaderBarItemBits nFlags );
+
+ USHORT GetId() const { return _nId; }
+
+ ULONG Width() { return _nWidth; }
+ Image& GetImage() { return _aImage; }
+ String& Title() { return _aTitle; }
+ HeaderBarItemBits& Flags() { return _nFlags; }
+
+ BOOL IsFrozen() const { return _bFrozen; }
+ void Freeze( BOOL bFreeze = TRUE ) { _bFrozen = bFreeze; }
+
+ virtual void Draw( BrowseBox& rBox, OutputDevice& rDev,
+ const Point& rPos, BOOL bCurs );
+
+ void SetWidth(ULONG nNewWidthPixel, const Fraction& rCurrentZoom);
+ void ZoomChanged(const Fraction& rNewZoom);
+};
+
+//===================================================================
+
+class BrowserDataWin: public Control
+{
+friend class BrowseBox;
+ BrowserHeader* pHeaderBar; // only for BROWSER_HEADERBAR_NEW
+ Window* pEventWin; // Window of forwarded events
+ ScrollBarBox* pCornerWin; // Window in the corner btw the ScrollBars
+ BOOL* pDtorNotify;
+ AutoTimer aMouseTimer; // recalls MouseMove on dragging out
+ MouseEvent aRepeatEvt; // a MouseEvent to repeat
+ Point aLastMousePos; // verhindert pseudo-MouseMoves
+
+ String aRealRowCount; // zur Anzeige im VScrollBar
+
+ RectangleList aInvalidRegion; // invalidated Rectangles during !UpdateMode
+ FASTBOOL bInPaint; // TRUE while in Paint
+ FASTBOOL bInCommand; // TRUE while in Command
+ FASTBOOL bNoScrollBack; // nur vorwaerts scrollen
+ FASTBOOL bNoHScroll; // kein horizontaler Scrollbar
+ FASTBOOL bAutoHScroll; // autohide horizontaler Scrollbar
+ FASTBOOL bAutoVScroll; // autohide horizontaler Scrollbar
+ FASTBOOL bUpdateMode; // nicht SV-UpdateMode wegen Invalidate()
+ FASTBOOL bAutoSizeLastCol;// last column always fills up window
+ FASTBOOL bHighlightAuto; // new auto-highlight by SetFont() etc.
+ FASTBOOL bResizeOnPaint; // outstanding resize-event
+ FASTBOOL bUpdateOnUnlock; // Update() while locked
+ FASTBOOL bInUpdateScrollbars; // Rekursionsschutz
+ FASTBOOL bHadRecursion; // Rekursion war aufgetreten
+ FASTBOOL bOwnDataChangedHdl; // dont change colors in DataChanged
+ USHORT nUpdateLock; // lock count, dont call Control::Update()!
+ short nCursorHidden; // new conuter for DoHide/ShowCursor
+
+public:
+ BrowserDataWin( BrowseBox* pParent );
+ ~BrowserDataWin();
+
+ virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual void Paint( const Rectangle& rRect );
+ virtual void RequestHelp( const HelpEvent& rHEvt );
+ virtual void Command( const CommandEvent& rEvt );
+ virtual void MouseButtonDown( const MouseEvent& rEvt );
+ virtual void MouseMove( const MouseEvent& rEvt );
+ DECL_LINK( RepeatedMouseMove, void * );
+
+ virtual void MouseButtonUp( const MouseEvent& rEvt );
+ virtual void KeyInput( const KeyEvent& rEvt );
+
+ virtual BOOL QueryDrop( DropEvent& rEvt );
+ virtual BOOL Drop( const DropEvent& rEvt );
+
+ BrowseEvent CreateBrowseEvent( const Point& rPosPixel );
+ void Repaint();
+ BrowseBox* GetParent() const
+ { return (BrowseBox*) Window::GetParent(); }
+ const String& GetRealRowCount() const { return aRealRowCount; }
+
+ void SetUpdateMode( BOOL bMode );
+ FASTBOOL GetUpdateMode() const { return bUpdateMode; }
+ void EnterUpdateLock() { ++nUpdateLock; }
+ void LeaveUpdateLock();
+ void Update();
+ void DoOutstandingInvalidations();
+ void Invalidate();
+ void Invalidate( const Rectangle& rRect );
+};
+
+//-------------------------------------------------------------------
+
+inline void BrowserDataWin::Repaint()
+{
+ if ( GetUpdateMode() )
+ Update();
+ Paint( Rectangle( Point(), GetOutputSizePixel() ) );
+}
+
+//===================================================================
+
+class BrowserScrollBar: public ScrollBar
+{
+ ULONG _nTip;
+ ULONG _nLastPos;
+ BrowserDataWin* _pDataWin;
+
+public:
+ BrowserScrollBar( Window* pParent, WinBits nStyle,
+ BrowserDataWin *pDataWin )
+ : ScrollBar( pParent, nStyle ),
+ _nTip( 0 ),
+ _nLastPos( ULONG_MAX ),
+ _pDataWin( pDataWin )
+ {}
+ //ScrollBar( Window* pParent, const ResId& rResId );
+
+ virtual void Tracking( const TrackingEvent& rTEvt );
+ virtual void EndScroll();
+};
+
+//===================================================================
+
+void InitSettings_Impl( Window *pWin,
+ BOOL bFont = TRUE, BOOL bForeground = TRUE, BOOL bBackground = TRUE );
+
+//===================================================================
+
+#ifdef DBG_MI
+
+void DoLog_Impl( const BrowseBox *pThis, const char *pWhat, const char *pWho );
+#define LOG(pThis,what,who) DoLog_Impl(pThis,what,who)
+
+#else
+
+#define LOG(pThis,what,who)
+
+#endif
+
+
+#endif
+
diff --git a/svtools/source/brwbox/makefile.mk b/svtools/source/brwbox/makefile.mk
new file mode 100644
index 000000000000..2379c21e72c1
--- /dev/null
+++ b/svtools/source/brwbox/makefile.mk
@@ -0,0 +1,99 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=SVTOOLS
+TARGET=browse
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+CXXFILES= \
+ brwbox1.cxx \
+ brwbox2.cxx \
+ brwhead.cxx \
+ datwin.cxx
+
+.IF "$(GUI)" == "WIN"
+CXXFILES+= \
+ brwdll.cxx
+.ENDIF
+
+SLOFILES= \
+ $(SLO)$/brwbox1.obj \
+ $(SLO)$/brwbox2.obj \
+ $(SLO)$/brwhead.obj \
+ $(SLO)$/datwin.obj
+
+.IF "$(GUI)" == "WIN"
+SLOFILES+= \
+ $(SLO)$/brwdll.obj
+.ENDIF
+# --- Targets -------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/svtools/source/config/makefile.mk b/svtools/source/config/makefile.mk
new file mode 100644
index 000000000000..b5b01fbbd6db
--- /dev/null
+++ b/svtools/source/config/makefile.mk
@@ -0,0 +1,82 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+PRJ=..$/..
+
+PRJNAME=SVTOOLS
+TARGET=config
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/pathoptions.obj \
+ $(SLO)$/useroptions.obj
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/svtools/source/config/pathoptions.cxx b/svtools/source/config/pathoptions.cxx
new file mode 100644
index 000000000000..4a659bed30d7
--- /dev/null
+++ b/svtools/source/config/pathoptions.cxx
@@ -0,0 +1,409 @@
+/*************************************************************************
+ *
+ * $RCSfile: pathoptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#include "pathoptions.hxx"
+
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+// class SvtPathOptions --------------------------------------------------
+
+// initialize the static member
+SvtPathOptions* SvtPathOptions::m_pOptions = NULL;
+
+// -----------------------------------------------------------------------
+
+Sequence< OUString > SvtPathOptions::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Addin", // PATH_ADDIN
+ "AutoCorrect", // PATH_AUTOCORRECT
+ "AutoPilot", // PATH_AUTOPILOT
+ "Backup", // PATH_BACKUP
+ "Basic", // PATH_BASIC
+ "Bitmap", // PATH_BITMAP
+ "Config", // PATH_CONFIG
+ "Database", // PATH_DATABASE
+ "Dictionary", // PATH_DICTIONARY
+ "Favorite", // PATH_FAVORITES
+ "Filter", // PATH_FILTER
+ "Gallery", // PATH_GALLERY
+ "Glossary", // PATH_GLOSSARY
+ "Graphic", // PATH_GRAPHIC
+ "Help", // PATH_HELP
+ "Linguistic", // PATH_LINGUISTIC
+ "Module", // PATH_MODULE
+ "New", // PATH_NEWMENU
+ "Palette", // PATH_PALETTE
+ "Plugin", // PATH_PLUGIN
+ "Storage", // PATH_STORAGE
+ "SubIni", // PATH_SUBINI
+ "Temp", // PATH_TEMP
+ "Template", // PATH_TEMPLATE
+ "Trash", // PATH_TRASH
+ "UserConfig", // PATH_USERCONFIG
+ "UserDictionary", // PATH_USERDICTIONARY
+ "Work" // PATH_WORK
+ };
+
+ const int nCount = 28;
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtPathOptions::GetPath( int nIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( PATH_ADDIN == nIndex )
+ return m_aAddinPath;
+ else if ( PATH_AUTOCORRECT == nIndex )
+ return m_aAutoCorrectPath;
+ else if ( PATH_AUTOPILOT == nIndex )
+ return m_aAutoPilotPath;
+ else if ( PATH_BACKUP == nIndex )
+ return m_aBackupPath;
+ else if ( PATH_BASIC == nIndex )
+ return m_aBasicPath;
+ else if ( PATH_BITMAP == nIndex )
+ return m_aBitmapPath;
+ else if ( PATH_CONFIG == nIndex )
+ return m_aConfigPath;
+ else if ( PATH_DATABASE == nIndex )
+ return m_aDatabasePath;
+ else if ( PATH_DICTIONARY == nIndex )
+ return m_aDictionaryPath;
+ else if ( PATH_FAVORITES == nIndex )
+ return m_aFavoritesPath;
+ else if ( PATH_FILTER == nIndex )
+ return m_aFilterPath;
+ else if ( PATH_GALLERY == nIndex )
+ return m_aGalleryPath;
+ else if ( PATH_GLOSSARY == nIndex )
+ return m_aGlossaryPath;
+ else if ( PATH_GRAPHIC == nIndex )
+ return m_aGraphicPath;
+ else if ( PATH_HELP == nIndex )
+ return m_aHelpPath;
+ else if ( PATH_LINGUISTIC == nIndex )
+ return m_aLinguisticPath;
+ else if ( PATH_MODULE == nIndex )
+ return m_aModulePath;
+ else if ( PATH_NEWMENU == nIndex )
+ return m_aNewMenuPath;
+ else if ( PATH_PALETTE == nIndex )
+ return m_aPalettePath;
+ else if ( PATH_PLUGIN == nIndex )
+ return m_aPluginPath;
+ else if ( PATH_STORAGE == nIndex )
+ return m_aStoragePath;
+ else if ( PATH_SUBINI == nIndex )
+ return m_aSubIniPath;
+ else if ( PATH_TEMP == nIndex )
+ return m_aTempPath;
+ else if ( PATH_TEMPLATE == nIndex )
+ return m_aTemplatePath;
+ else if ( PATH_TRASH == nIndex )
+ return m_aTrashPath;
+ else if ( PATH_USERCONFIG == nIndex )
+ return m_aUserConfigPath;
+ else if ( PATH_USERDICTIONARY == nIndex )
+ return m_aUserDictionaryPath;
+ else if ( PATH_WORK == nIndex )
+ return m_aWorkPath;
+ else
+ {
+ DBG_ERRORFILE( "invalid index to get a path" );
+ return m_aEmptyString;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtPathOptions::SetPath( int nIndex, const String& rNewPath )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( PATH_ADDIN == nIndex )
+ m_aAddinPath = rNewPath;
+ else if ( PATH_AUTOCORRECT == nIndex )
+ m_aAutoCorrectPath = rNewPath;
+ else if ( PATH_AUTOPILOT == nIndex )
+ m_aAutoPilotPath = rNewPath;
+ else if ( PATH_BACKUP == nIndex )
+ m_aBackupPath = rNewPath;
+ else if ( PATH_BASIC == nIndex )
+ m_aBasicPath = rNewPath;
+ else if ( PATH_BITMAP == nIndex )
+ m_aBitmapPath = rNewPath;
+ else if ( PATH_CONFIG == nIndex )
+ m_aConfigPath = rNewPath;
+ else if ( PATH_DATABASE == nIndex )
+ m_aDatabasePath = rNewPath;
+ else if ( PATH_DICTIONARY == nIndex )
+ m_aDictionaryPath = rNewPath;
+ else if ( PATH_FAVORITES == nIndex )
+ m_aFavoritesPath = rNewPath;
+ else if ( PATH_FILTER == nIndex )
+ m_aFilterPath = rNewPath;
+ else if ( PATH_GALLERY == nIndex )
+ m_aGalleryPath = rNewPath;
+ else if ( PATH_GLOSSARY == nIndex )
+ m_aGlossaryPath = rNewPath;
+ else if ( PATH_GRAPHIC == nIndex )
+ m_aGraphicPath = rNewPath;
+ else if ( PATH_HELP == nIndex )
+ m_aHelpPath = rNewPath;
+ else if ( PATH_LINGUISTIC == nIndex )
+ m_aLinguisticPath = rNewPath;
+ else if ( PATH_MODULE == nIndex )
+ m_aModulePath = rNewPath;
+ else if ( PATH_NEWMENU == nIndex )
+ m_aNewMenuPath = rNewPath;
+ else if ( PATH_PALETTE == nIndex )
+ m_aPalettePath = rNewPath;
+ else if ( PATH_PLUGIN == nIndex )
+ m_aPluginPath = rNewPath;
+ else if ( PATH_STORAGE == nIndex )
+ m_aStoragePath = rNewPath;
+ else if ( PATH_SUBINI == nIndex )
+ m_aSubIniPath = rNewPath;
+ else if ( PATH_TEMP == nIndex )
+ m_aTempPath = rNewPath;
+ else if ( PATH_TEMPLATE == nIndex )
+ m_aTemplatePath = rNewPath;
+ else if ( PATH_TRASH == nIndex )
+ m_aTrashPath = rNewPath;
+ else if ( PATH_USERCONFIG == nIndex )
+ m_aUserConfigPath = rNewPath;
+ else if ( PATH_USERDICTIONARY == nIndex )
+ m_aUserDictionaryPath = rNewPath;
+ else if ( PATH_WORK == nIndex )
+ m_aWorkPath = rNewPath;
+ else
+ DBG_ERRORFILE( "invalid index to set a path" );
+ SetModified();
+}
+
+// -----------------------------------------------------------------------
+
+SvtPathOptions::SvtPathOptions() : ConfigItem( OUString::createFromAscii("Office/Common/Path") )
+{
+ Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ EnableNotification( aNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == aNames.getLength() )
+ {
+ OUString aTempStr;
+
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ pValues[nProp] >>= aTempStr;
+ switch ( nProp )
+ {
+ case PATH_ADDIN: m_aAddinPath = String( aTempStr ); break;
+ case PATH_AUTOCORRECT: m_aAutoCorrectPath = String( aTempStr ); break;
+ case PATH_AUTOPILOT: m_aAutoPilotPath = String( aTempStr ); break;
+ case PATH_BACKUP: m_aBackupPath = String( aTempStr ); break;
+ case PATH_BASIC: m_aBasicPath = String( aTempStr ); break;
+ case PATH_BITMAP: m_aBitmapPath = String( aTempStr ); break;
+ case PATH_CONFIG: m_aConfigPath = String( aTempStr ); break;
+ case PATH_DATABASE: m_aDatabasePath = String( aTempStr ); break;
+ case PATH_DICTIONARY: m_aDictionaryPath = String( aTempStr ); break;
+ case PATH_FAVORITES: m_aFavoritesPath = String( aTempStr ); break;
+ case PATH_FILTER: m_aFilterPath = String( aTempStr ); break;
+ case PATH_GALLERY: m_aGalleryPath = String( aTempStr ); break;
+ case PATH_GLOSSARY: m_aGlossaryPath = String( aTempStr ); break;
+ case PATH_GRAPHIC: m_aGraphicPath = String( aTempStr ); break;
+ case PATH_HELP: m_aHelpPath = String( aTempStr ); break;
+ case PATH_LINGUISTIC: m_aLinguisticPath = String( aTempStr ); break;
+ case PATH_MODULE: m_aModulePath = String( aTempStr ); break;
+ case PATH_NEWMENU: m_aNewMenuPath = String( aTempStr ); break;
+ case PATH_PALETTE: m_aPalettePath = String( aTempStr ); break;
+ case PATH_PLUGIN: m_aPluginPath = String( aTempStr ); break;
+ case PATH_STORAGE: m_aStoragePath = String( aTempStr ); break;
+ case PATH_SUBINI: m_aSubIniPath = String( aTempStr ); break;
+ case PATH_TEMP: m_aTempPath = String( aTempStr ); break;
+ case PATH_TEMPLATE: m_aTemplatePath = String( aTempStr ); break;
+ case PATH_TRASH: m_aTrashPath = String( aTempStr ); break;
+ case PATH_USERCONFIG: m_aUserConfigPath = String( aTempStr ); break;
+ case PATH_USERDICTIONARY: m_aUserDictionaryPath = String( aTempStr ); break;
+ case PATH_WORK: m_aWorkPath = String( aTempStr ); break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to load a path" );
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvtPathOptions::~SvtPathOptions()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvtPathOptions* SvtPathOptions::GetPathOptions()
+{
+ if ( !m_pOptions )
+ m_pOptions = new SvtPathOptions;
+ return m_pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+void SvtPathOptions::DestroyPathOptions()
+{
+ if ( m_pOptions )
+ DELETEZ( m_pOptions );
+}
+
+// -----------------------------------------------------------------------
+
+void SvtPathOptions::Commit()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Sequence< OUString > aNames = GetPropertyNames();
+ OUString* pNames = aNames.getArray();
+ Sequence< Any > aValues( aNames.getLength() );
+ Any* pValues = aValues.getArray();
+ const Type& rType = ::getBooleanCppuType();
+ OUString aTempStr;
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ switch ( nProp )
+ {
+ case PATH_ADDIN: aTempStr = OUString( m_aAddinPath ); break;
+ case PATH_AUTOCORRECT: aTempStr = OUString( m_aAutoCorrectPath ); break;
+ case PATH_AUTOPILOT: aTempStr = OUString( m_aAutoPilotPath ); break;
+ case PATH_BACKUP: aTempStr = OUString( m_aBackupPath ); break;
+ case PATH_BASIC: aTempStr = OUString( m_aBasicPath ); break;
+ case PATH_BITMAP: aTempStr = OUString( m_aBitmapPath ); break;
+ case PATH_CONFIG: aTempStr = OUString( m_aConfigPath ); break;
+ case PATH_DATABASE: aTempStr = OUString( m_aDatabasePath ); break;
+ case PATH_DICTIONARY: aTempStr = OUString( m_aDictionaryPath ); break;
+ case PATH_FAVORITES: aTempStr = OUString( m_aFavoritesPath ); break;
+ case PATH_FILTER: aTempStr = OUString( m_aFilterPath ); break;
+ case PATH_GALLERY: aTempStr = OUString( m_aGalleryPath ); break;
+ case PATH_GLOSSARY: aTempStr = OUString( m_aGlossaryPath ); break;
+ case PATH_GRAPHIC: aTempStr = OUString( m_aGraphicPath ); break;
+ case PATH_HELP: aTempStr = OUString( m_aHelpPath ); break;
+ case PATH_LINGUISTIC: aTempStr = OUString( m_aLinguisticPath ); break;
+ case PATH_MODULE: aTempStr = OUString( m_aModulePath ); break;
+ case PATH_NEWMENU: aTempStr = OUString( m_aNewMenuPath ); break;
+ case PATH_PALETTE: aTempStr = OUString( m_aPalettePath ); break;
+ case PATH_PLUGIN: aTempStr = OUString( m_aPluginPath ); break;
+ case PATH_STORAGE: aTempStr = OUString( m_aStoragePath ); break;
+ case PATH_SUBINI: aTempStr = OUString( m_aSubIniPath ); break;
+ case PATH_TEMP: aTempStr = OUString( m_aTempPath ); break;
+ case PATH_TEMPLATE: aTempStr = OUString( m_aTemplatePath ); break;
+ case PATH_TRASH: aTempStr = OUString( m_aTrashPath ); break;
+ case PATH_USERCONFIG: aTempStr = OUString( m_aUserConfigPath ); break;
+ case PATH_USERDICTIONARY: aTempStr = OUString( m_aUserDictionaryPath ); break;
+ case PATH_WORK: aTempStr = OUString( m_aWorkPath ); break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to save a path" );
+ }
+ pValues[nProp] <<= aTempStr;
+ }
+ PutProperties( aNames, aValues );
+}
+
+// -----------------------------------------------------------------------
+
+void SvtPathOptions::Notify( const Sequence<rtl::OUString>& aPropertyNames )
+{
+ DBG_ERRORFILE( "properties have been changed" );
+}
+
diff --git a/svtools/source/config/useroptions.cxx b/svtools/source/config/useroptions.cxx
new file mode 100644
index 000000000000..578978f6f075
--- /dev/null
+++ b/svtools/source/config/useroptions.cxx
@@ -0,0 +1,325 @@
+/*************************************************************************
+ *
+ * $RCSfile: useroptions.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#pragma hdrstop
+
+#include "useroptions.hxx"
+
+#ifndef _UTL_CONFIGMGR_HXX_
+#include <unotools/configmgr.hxx>
+#endif
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
+#include <com/sun/star/uno/Any.hxx>
+#endif
+#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
+#include <com/sun/star/uno/Sequence.hxx>
+#endif
+
+using namespace utl;
+using namespace rtl;
+using namespace com::sun::star::uno;
+
+// class SvtUserOptions --------------------------------------------------
+
+// initialize the static member
+SvtUserOptions* SvtUserOptions::m_pOptions = NULL;
+
+// -----------------------------------------------------------------------
+
+Sequence< OUString > SvtUserOptions::GetPropertyNames()
+{
+ static const char* aPropNames[] =
+ {
+ "Company", // USER_COMPANY
+ "FirstName", // USER_FIRSTNAME
+ "LastName", // USER_LASTNAME
+ "UserID", // USER_ID
+ "Street", // USER_STREET
+ "City", // USER_CITY
+ "State", // USER_STATE
+ "Zip", // USER_ZIP
+ "Country", // USER_COUNTRY
+ "Position", // USER_POSITION
+ "Title", // USER_TITLE
+ "TelephoneHome", // USER_TELEPHONEHOME
+ "TelephoneWork", // USER_TELEPHONEWORK
+ "Fax", // USER_FAX
+ "EMail", // USER_EMAIL
+ "CustomerNumber" // USER_CUSTOMERNUMBER
+ };
+
+ const int nCount = 16;
+ Sequence< OUString > aNames( nCount );
+ OUString* pNames = aNames.getArray();
+ for ( int i = 0; i < nCount; i++ )
+ pNames[i] = OUString::createFromAscii( aPropNames[i] );
+
+ return aNames;
+}
+
+// -----------------------------------------------------------------------
+
+const String& SvtUserOptions::GetUserToken( int nIndex )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( USER_COMPANY == nIndex )
+ return m_aCompany;
+ else if ( USER_FIRSTNAME == nIndex )
+ return m_aFirstName;
+ else if ( USER_LASTNAME == nIndex )
+ return m_aLastName;
+ else if ( USER_ID == nIndex )
+ return m_aID;
+ else if ( USER_STREET == nIndex )
+ return m_aStreet;
+ else if ( USER_CITY == nIndex )
+ return m_aCity;
+ else if ( USER_STATE == nIndex )
+ return m_aState;
+ else if ( USER_ZIP == nIndex )
+ return m_aZip;
+ else if ( USER_COUNTRY == nIndex )
+ return m_aCountry;
+ else if ( USER_POSITION == nIndex )
+ return m_aPosition;
+ else if ( USER_TITLE == nIndex )
+ return m_aTitle;
+ else if ( USER_TELEPHONEHOME == nIndex )
+ return m_aTelephoneHome;
+ else if ( USER_TELEPHONEWORK == nIndex )
+ return m_aTelephoneWork;
+ else if ( USER_FAX == nIndex )
+ return m_aFax;
+ else if ( USER_EMAIL == nIndex )
+ return m_aEmail;
+ else if ( USER_CUSTOMERNUMBER == nIndex )
+ return m_aCustomerNumber;
+ else
+ {
+ DBG_ERRORFILE( "invalid index to get a user token" );
+ return m_aEmptyString;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions::SetUserToken( int nIndex, const String& rNewToken )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( USER_COMPANY == nIndex )
+ m_aCompany = rNewToken;
+ else if ( USER_FIRSTNAME == nIndex )
+ m_aFirstName = rNewToken;
+ else if ( USER_LASTNAME == nIndex )
+ m_aLastName = rNewToken;
+ else if ( USER_ID == nIndex )
+ m_aID = rNewToken;
+ else if ( USER_STREET == nIndex )
+ m_aStreet = rNewToken;
+ else if ( USER_CITY == nIndex )
+ m_aCity = rNewToken;
+ else if ( USER_STATE == nIndex )
+ m_aState = rNewToken;
+ else if ( USER_ZIP == nIndex )
+ m_aZip = rNewToken;
+ else if ( USER_COUNTRY == nIndex )
+ m_aCountry = rNewToken;
+ else if ( USER_POSITION == nIndex )
+ m_aPosition = rNewToken;
+ else if ( USER_TITLE == nIndex )
+ m_aTitle = rNewToken;
+ else if ( USER_TELEPHONEHOME == nIndex )
+ m_aTelephoneHome = rNewToken;
+ else if ( USER_TELEPHONEWORK == nIndex )
+ m_aTelephoneWork = rNewToken;
+ else if ( USER_FAX == nIndex )
+ m_aFax = rNewToken;
+ else if ( USER_EMAIL == nIndex )
+ m_aEmail = rNewToken;
+ else if ( USER_CUSTOMERNUMBER == nIndex )
+ m_aCustomerNumber = rNewToken;
+ else
+ DBG_ERRORFILE( "invalid index to set a user token" );
+ SetModified();
+}
+
+// -----------------------------------------------------------------------
+
+SvtUserOptions::SvtUserOptions() : ConfigItem( OUString::createFromAscii("UserProfile/Data") )
+{
+ Sequence< OUString > aNames = GetPropertyNames();
+ Sequence< Any > aValues = GetProperties( aNames );
+ EnableNotification( aNames );
+ const Any* pValues = aValues.getConstArray();
+ DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
+ if ( aValues.getLength() == aNames.getLength() )
+ {
+ OUString aTempStr;
+
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" );
+ if ( pValues[nProp].hasValue() )
+ {
+ pValues[nProp] >>= aTempStr;
+ switch ( nProp )
+ {
+ case USER_COMPANY: m_aCompany = String( aTempStr ); break;
+ case USER_FIRSTNAME: m_aFirstName = String( aTempStr ); break;
+ case USER_LASTNAME: m_aLastName = String( aTempStr ); break;
+ case USER_ID: m_aID = String( aTempStr ); break;
+ case USER_STREET: m_aStreet = String( aTempStr ); break;
+ case USER_CITY: m_aCity = String( aTempStr ); break;
+ case USER_STATE: m_aState = String( aTempStr ); break;
+ case USER_ZIP: m_aZip = String( aTempStr ); break;
+ case USER_COUNTRY: m_aCountry = String( aTempStr ); break;
+ case USER_POSITION: m_aPosition = String( aTempStr ); break;
+ case USER_TITLE: m_aTitle = String( aTempStr ); break;
+ case USER_TELEPHONEHOME: m_aTelephoneHome = String( aTempStr ); break;
+ case USER_TELEPHONEWORK: m_aTelephoneWork = String( aTempStr ); break;
+ case USER_FAX: m_aFax = String( aTempStr ); break;
+ case USER_EMAIL: m_aEmail = String( aTempStr ); break;
+ case USER_CUSTOMERNUMBER: m_aCustomerNumber = String( aTempStr ); break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to load a user token" );
+ }
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SvtUserOptions::~SvtUserOptions()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SvtUserOptions* SvtUserOptions::GetUserOptions()
+{
+ if ( !m_pOptions )
+ m_pOptions = new SvtUserOptions;
+ return m_pOptions;
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions::DestroyUserOptions()
+{
+ if ( m_pOptions )
+ DELETEZ( m_pOptions );
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions::Commit()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Sequence< OUString > aNames = GetPropertyNames();
+ OUString* pNames = aNames.getArray();
+ Sequence< Any > aValues( aNames.getLength() );
+ Any* pValues = aValues.getArray();
+ const Type& rType = ::getBooleanCppuType();
+ OUString aTempStr;
+ for ( int nProp = 0; nProp < aNames.getLength(); nProp++ )
+ {
+ switch ( nProp )
+ {
+ case USER_COMPANY: aTempStr = OUString( m_aCompany ); break;
+ case USER_FIRSTNAME: aTempStr = OUString( m_aFirstName ); break;
+ case USER_LASTNAME: aTempStr = OUString( m_aLastName ); break;
+ case USER_ID: aTempStr = OUString( m_aID ); break;
+ case USER_STREET: aTempStr = OUString( m_aStreet ); break;
+ case USER_CITY: aTempStr = OUString( m_aCity ); break;
+ case USER_STATE: aTempStr = OUString( m_aState ); break;
+ case USER_ZIP: aTempStr = OUString( m_aZip ); break;
+ case USER_COUNTRY: aTempStr = OUString( m_aCountry ); break;
+ case USER_POSITION: aTempStr = OUString( m_aPosition ); break;
+ case USER_TITLE: aTempStr = OUString( m_aTitle ); break;
+ case USER_TELEPHONEHOME: aTempStr = OUString( m_aTelephoneHome ); break;
+ case USER_TELEPHONEWORK: aTempStr = OUString( m_aTelephoneWork ); break;
+ case USER_FAX: aTempStr = OUString( m_aFax ); break;
+ case USER_EMAIL: aTempStr = OUString( m_aEmail ); break;
+ case USER_CUSTOMERNUMBER: aTempStr = OUString( m_aCustomerNumber ); break;
+
+ default:
+ DBG_ERRORFILE( "invalid index to save a user token" );
+ }
+ pValues[nProp] <<= aTempStr;
+ }
+ PutProperties( aNames, aValues );
+}
+
+// -----------------------------------------------------------------------
+
+void SvtUserOptions::Notify( const Sequence<rtl::OUString>& aPropertyNames )
+{
+ DBG_ERRORFILE( "properties have been changed" );
+}
+
diff --git a/svtools/source/contnr/cont_pch.cxx b/svtools/source/contnr/cont_pch.cxx
new file mode 100644
index 000000000000..4753a03158dc
--- /dev/null
+++ b/svtools/source/contnr/cont_pch.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * $RCSfile: cont_pch.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <sv.hxx>
+#include "treelist.hxx"
+#include "svtabbx.hxx"
+#include "svtreebx.hxx"
+#include "svicnvw.hxx"
+#include "svimpbox.hxx"
+#include "svimpicn.hxx"
+#include "svlbox.hxx"
+#include "svlbitm.hxx"
+
+#pragma hdrstop
+
diff --git a/svtools/source/contnr/ctrdll.cxx b/svtools/source/contnr/ctrdll.cxx
new file mode 100644
index 000000000000..20729e743e5b
--- /dev/null
+++ b/svtools/source/contnr/ctrdll.cxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * $RCSfile: ctrdll.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifdef WIN
+
+#ifndef _SVWIN_H
+#include <svwin.h>
+#endif
+
+#ifndef _SYSDEP_HXX
+#include <sysdep.hxx>
+#endif
+
+// Statische DLL-Verwaltungs-Variablen
+static HINSTANCE hDLLInst = 0; // HANDLE der DLL
+
+
+/***************************************************************************
+|*
+|* LibMain()
+|*
+|* Beschreibung Initialisierungsfunktion der DLL
+|* Ersterstellung TH 05.05.93
+|* Letzte Aenderung TH 05.05.93
+|*
+***************************************************************************/
+
+extern "C" int CALLBACK LibMain( HINSTANCE hDLL, WORD, WORD nHeap, LPSTR )
+{
+#ifndef WNT
+ if ( nHeap )
+ UnlockData( 0 );
+#endif
+
+ hDLLInst = hDLL;
+
+ return TRUE;
+}
+
+/***************************************************************************
+|*
+|* WEP()
+|*
+|* Beschreibung DLL-Deinitialisierung
+|* Ersterstellung TH 05.05.93
+|* Letzte Aenderung TH 05.05.93
+|*
+***************************************************************************/
+
+extern "C" int CALLBACK WEP( int )
+{
+ return 1;
+}
+
+#endif
diff --git a/svtools/source/contnr/makefile.mk b/svtools/source/contnr/makefile.mk
new file mode 100644
index 000000000000..cddb84f1bc6c
--- /dev/null
+++ b/svtools/source/contnr/makefile.mk
@@ -0,0 +1,134 @@
+#*************************************************************************
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.1.1.1 $
+#
+# last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+#
+# The Contents of this file are made available subject to the terms of
+# either of the following licenses
+#
+# - GNU Lesser General Public License Version 2.1
+# - Sun Industry Standards Source License Version 1.1
+#
+# Sun Microsystems Inc., October, 2000
+#
+# GNU Lesser General Public License Version 2.1
+# =============================================
+# Copyright 2000 by Sun Microsystems, Inc.
+# 901 San Antonio Road, Palo Alto, CA 94303, USA
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License version 2.1, as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+#
+# Sun Industry Standards Source License Version 1.1
+# =================================================
+# The contents of this file are subject to the Sun Industry Standards
+# Source License Version 1.1 (the "License"); You may not use this file
+# except in compliance with the License. You may obtain a copy of the
+# License at http://www.openoffice.org/license.html.
+#
+# Software provided under this License is provided on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+# See the License for the specific provisions governing your rights and
+# obligations concerning the Software.
+#
+# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+#
+# Copyright: 2000 by Sun Microsystems, Inc.
+#
+# All Rights Reserved.
+#
+# Contributor(s): _______________________________________
+#
+#
+#
+#*************************************************************************
+
+PRJ=..$/..
+
+PRJNAME=SVTOOLS
+TARGET=svcontnr
+
+PROJECTPCH4DLL=TRUE
+PROJECTPCH=cont_pch
+PROJECTPCHSOURCE=cont_pch
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : svpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sv.mk
+
+# --- Files --------------------------------------------------------
+
+.IF "$(COM)"=="WTC"
+CFLAGS=$(CFLAGS) -od -3r
+.ENDIF
+
+.IF "$(header)" == ""
+
+CXXFILES= svtabbx.cxx \
+ svicnvw.cxx \
+ svimpicn.cxx \
+ treelist.cxx \
+ svlbox.cxx \
+ svimpbox.cxx \
+ svlbitm.cxx \
+ svtreebx.cxx \
+ cont_pch.cxx \
+ ctrdll.cxx
+
+SLOFILES= $(SLO)$/svtabbx.obj \
+ $(SLO)$/svicnvw.obj \
+ $(SLO)$/svimpicn.obj \
+ $(SLO)$/treelist.obj \
+ $(SLO)$/svlbox.obj \
+ $(SLO)$/svimpbox.obj \
+ $(SLO)$/svlbitm.obj \
+ $(SLO)$/svtreebx.obj
+
+# Fuer das Setup bauen wir noch mal statisch
+.IF "$(VCSID)" != "OV"
+
+OBJFILES= $(OBJ)$/svtabbx.obj \
+ $(OBJ)$/svicnvw.obj \
+ $(OBJ)$/svimpicn.obj \
+ $(OBJ)$/treelist.obj \
+ $(OBJ)$/svlbox.obj \
+ $(OBJ)$/svimpbox.obj \
+ $(OBJ)$/svlbitm.obj \
+ $(OBJ)$/svtreebx.obj
+
+.ENDIF
+
+.ENDIF
+
+HXX1TARGET= svcontnr
+HXX1EXT= hxx
+HXX1FILES= $(PRJ)$/inc$/svlbox.hxx \
+ $(PRJ)$/inc$/svlbitm.hxx \
+ $(PRJ)$/inc$/svtreebx.hxx \
+ $(PRJ)$/inc$/svicnvw.hxx \
+ $(PRJ)$/inc$/svtabbx.hxx \
+ $(PRJ)$/inc$/treelist.hxx
+HXX1EXCL= -E:*include*
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/svtools/source/contnr/svicnvw.cxx b/svtools/source/contnr/svicnvw.cxx
new file mode 100644
index 000000000000..e2948c69e60a
--- /dev/null
+++ b/svtools/source/contnr/svicnvw.cxx
@@ -0,0 +1,855 @@
+/*************************************************************************
+ *
+ * $RCSfile: svicnvw.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <svlbox.hxx>
+#include <svicnvw.hxx>
+#include <svimpicn.hxx>
+#include <svlbitm.hxx>
+
+#pragma hdrstop
+
+#define ICNVW_BLOCK_ENTRYINS 0x0001
+
+SvIcnVwDataEntry::SvIcnVwDataEntry()
+ : nIcnVwFlags(0),eTextMode(ShowTextDontKnow)
+{
+}
+
+SvIcnVwDataEntry::~SvIcnVwDataEntry()
+{
+}
+
+SvIconView::SvIconView( Window* pParent, WinBits nWinStyle ) :
+ SvLBox( pParent, nWinStyle | WB_BORDER )
+{
+ nWinBits = nWinStyle;
+ nIcnVwFlags = 0;
+ pImp = new SvImpIconView( this, GetModel(), nWinStyle | WB_ICON );
+ pImp->pViewData = 0;
+ SetSelectionMode( SINGLE_SELECTION );
+ SetLineColor();
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
+ SetDefaultFont();
+}
+
+SvIconView::SvIconView( Window* pParent , const ResId& rResId ) :
+ SvLBox( pParent, rResId )
+{
+ pImp = new SvImpIconView( this, GetModel(), WB_BORDER | WB_ICON );
+ nIcnVwFlags = 0;
+ pImp->pViewData = 0;
+ SetLineColor();
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+ SetBackground( Wallpaper( rStyleSettings.GetFieldColor() ) );
+ SetDefaultFont();
+ pImp->SetSelectionMode( GetSelectionMode() );
+ pImp->SetWindowBits( nWindowStyle );
+ nWinBits = nWindowStyle;
+}
+
+SvIconView::~SvIconView()
+{
+ delete pImp;
+}
+
+void SvIconView::SetDefaultFont()
+{
+ SetFont( GetFont() );
+}
+
+SvLBoxEntry* SvIconView::CreateEntry( const XubString& rStr,
+ const Image& rCollEntryBmp, const Image& rExpEntryBmp )
+{
+ SvLBoxEntry* pEntry = new SvLBoxEntry;
+
+ SvLBoxContextBmp* pContextBmp =
+ new SvLBoxContextBmp( pEntry,0, rCollEntryBmp,rExpEntryBmp, 0xffff );
+ pEntry->AddItem( pContextBmp );
+
+ SvLBoxString* pString = new SvLBoxString( pEntry, 0, rStr );
+ pEntry->AddItem( pString );
+
+ return pEntry;
+}
+
+void SvIconView::DisconnectFromModel()
+{
+ SvLBox::DisconnectFromModel();
+ pImp->SetModel( GetModel(), 0 );
+}
+
+
+SvLBoxEntry* SvIconView::InsertEntry( const XubString& rText,
+ SvLBoxEntry* pParent, BOOL bChildsOnDemand, ULONG nPos )
+{
+ SvLBoxEntry* pEntry = CreateEntry(
+ rText, aCollapsedEntryBmp, aExpandedEntryBmp );
+ pEntry->EnableChildsOnDemand( bChildsOnDemand );
+
+ if ( !pParent )
+ SvLBox::Insert( pEntry, nPos );
+ else
+ SvLBox::Insert( pEntry, pParent, nPos );
+ return pEntry;
+}
+
+SvLBoxEntry* SvIconView::InsertEntry( const XubString& rText,
+ const Image& rExpEntryBmp,
+ const Image& rCollEntryBmp,
+ SvLBoxEntry* pParent, BOOL bChildsOnDemand, ULONG nPos)
+{
+ SvLBoxEntry* pEntry = CreateEntry(
+ rText, rCollEntryBmp, rExpEntryBmp );
+
+ pEntry->EnableChildsOnDemand( bChildsOnDemand );
+ if ( !pParent )
+ SvLBox::Insert( pEntry, nPos );
+ else
+ SvLBox::Insert( pEntry, pParent, nPos );
+ return pEntry;
+}
+
+
+void SvIconView::SetEntryText(SvLBoxEntry* pEntry, const XubString& rStr)
+{
+ SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if ( pItem )
+ {
+ pItem->SetText( pEntry, rStr );
+ GetModel()->InvalidateEntry( pEntry );
+ }
+}
+
+void SvIconView::SetExpandedEntryBmp(SvLBoxEntry* pEntry, const Image& rBmp)
+{
+ SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if ( pItem )
+ {
+ pItem->SetBitmap2( pEntry, rBmp );
+ GetModel()->InvalidateEntry( pEntry );
+ }
+}
+
+void SvIconView::SetCollapsedEntryBmp(SvLBoxEntry* pEntry,
+ const Image& rBmp )
+{
+ SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if ( pItem )
+ {
+ pItem->SetBitmap1( pEntry, rBmp );
+ GetModel()->InvalidateEntry( pEntry );
+ }
+}
+
+XubString SvIconView::GetEntryText(SvLBoxEntry* pEntry ) const
+{
+ XubString aStr;
+ SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if ( pItem )
+ aStr = pItem->GetText();
+ return aStr;
+}
+
+Image SvIconView::GetExpandedEntryBmp(SvLBoxEntry* pEntry) const
+{
+ Image aBmp;
+ SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if ( pItem )
+ aBmp = pItem->GetBitmap2();
+ return aBmp;
+}
+
+Image SvIconView::GetCollapsedEntryBmp(SvLBoxEntry* pEntry) const
+{
+ Image aBmp;
+ SvLBoxContextBmp* pItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if ( pItem )
+ aBmp = pItem->GetBitmap1();
+ return aBmp;
+}
+
+
+SvLBoxEntry* SvIconView::CloneEntry( SvLBoxEntry* pSource )
+{
+ XubString aStr;
+ Image aCollEntryBmp;
+ Image aExpEntryBmp;
+
+ SvLBoxString* pStringItem = (SvLBoxString*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if ( pStringItem )
+ aStr = pStringItem->GetText();
+ SvLBoxContextBmp* pBmpItem =(SvLBoxContextBmp*)(pSource->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if ( pBmpItem )
+ {
+ aCollEntryBmp = pBmpItem->GetBitmap1();
+ aExpEntryBmp = pBmpItem->GetBitmap2();
+ }
+ SvLBoxEntry* pEntry = CreateEntry( aStr, aCollEntryBmp, aExpEntryBmp );
+ pEntry->SvListEntry::Clone( pSource );
+ pEntry->EnableChildsOnDemand( pSource->HasChildsOnDemand() );
+ pEntry->SetUserData( pSource->GetUserData() );
+ return pEntry;
+}
+
+
+USHORT SvIconView::IsA()
+{
+ return SV_LISTBOX_ID_ICONVIEW;
+}
+
+void SvIconView::RequestingChilds( SvLBoxEntry* pParent )
+{
+ if ( !pParent->HasChilds() )
+ InsertEntry( String::CreateFromAscii("<dummy>"), pParent, FALSE, LIST_APPEND );
+}
+
+void __EXPORT SvIconView::Paint( const Rectangle& rRect )
+{
+ pImp->Paint( rRect );
+}
+
+void __EXPORT SvIconView::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ pImp->MouseButtonDown( rMEvt );
+}
+
+void __EXPORT SvIconView::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ pImp->MouseButtonUp( rMEvt );
+}
+
+void __EXPORT SvIconView::MouseMove( const MouseEvent& rMEvt )
+{
+ pImp->MouseMove( rMEvt );
+}
+
+void __EXPORT SvIconView::KeyInput( const KeyEvent& rKEvt )
+{
+ // unter OS/2 bekommen wir auch beim Editieren Key-Up/Down
+ if( IsEditingActive() )
+ return;
+
+ nImpFlags |= SVLBOX_IS_TRAVELSELECT;
+ BOOL bKeyUsed = pImp->KeyInput( rKEvt );
+ if ( !bKeyUsed )
+ SvLBox::KeyInput( rKEvt );
+ nImpFlags &= ~SVLBOX_IS_TRAVELSELECT;
+}
+
+void __EXPORT SvIconView::Resize()
+{
+ pImp->Resize();
+ SvLBox::Resize();
+}
+
+void __EXPORT SvIconView::GetFocus()
+{
+ pImp->GetFocus();
+ SvLBox::GetFocus();
+}
+
+void __EXPORT SvIconView::LoseFocus()
+{
+ pImp->LoseFocus();
+ SvLBox::LoseFocus();
+}
+
+void SvIconView::SetUpdateMode( BOOL bUpdate )
+{
+ Control::SetUpdateMode( bUpdate );
+ if ( bUpdate )
+ pImp->UpdateAll();
+}
+
+void SvIconView::SetModel( SvLBoxTreeList* pNewModel )
+{
+}
+
+void SvIconView::SetModel( SvLBoxTreeList* pNewModel, SvLBoxEntry* pParent )
+{
+ nIcnVwFlags |= ICNVW_BLOCK_ENTRYINS;
+ SvLBox::SetModel( pNewModel );
+ nIcnVwFlags &= (~ICNVW_BLOCK_ENTRYINS);
+ if ( pParent && pParent->HasChildsOnDemand() )
+ RequestingChilds( pParent );
+ pImp->SetModel( pNewModel, pParent );
+}
+
+void __EXPORT SvIconView::ModelHasCleared()
+{
+ SvLBox::ModelHasCleared();
+ pImp->Clear();
+}
+
+void __EXPORT SvIconView::ModelHasInserted( SvListEntry* pEntry )
+{
+ if( !(nIcnVwFlags & ICNVW_BLOCK_ENTRYINS ) )
+ pImp->EntryInserted( (SvLBoxEntry*)pEntry );
+}
+
+void __EXPORT SvIconView::ModelHasInsertedTree( SvListEntry* pEntry )
+{
+ pImp->TreeInserted( (SvLBoxEntry*)pEntry );
+}
+
+void __EXPORT SvIconView::ModelIsMoving(SvListEntry* pSource,
+ SvListEntry* /* pTargetParent */ , ULONG /* nChildPos */ )
+{
+ pImp->MovingEntry( (SvLBoxEntry*)pSource );
+}
+
+void __EXPORT SvIconView::ModelHasMoved(SvListEntry* pSource )
+{
+ pImp->EntryMoved( (SvLBoxEntry*)pSource );
+}
+
+void __EXPORT SvIconView::ModelIsRemoving( SvListEntry* pEntry )
+{
+ pImp->RemovingEntry( (SvLBoxEntry*)pEntry );
+ NotifyRemoving( (SvLBoxEntry*)pEntry );
+}
+
+void __EXPORT SvIconView::ModelHasRemoved( SvListEntry* /* pEntry */ )
+{
+ pImp->EntryRemoved();
+}
+
+void __EXPORT SvIconView::ModelHasEntryInvalidated( SvListEntry* pEntry )
+{
+ // die einzelnen Items des Entries reinitialisieren
+ SvLBox::ModelHasEntryInvalidated( pEntry );
+ // painten
+ pImp->ModelHasEntryInvalidated( pEntry );
+}
+
+void SvIconView::ShowTargetEmphasis( SvLBoxEntry* pEntry, BOOL bShow )
+{
+ pImp->ShowTargetEmphasis( pEntry, bShow );
+}
+
+Point SvIconView::GetEntryPos( SvLBoxEntry* pEntry ) const
+{
+ return ((SvIconView*)this)->pImp->GetEntryPos( pEntry );
+}
+
+void SvIconView::SetEntryPos( SvLBoxEntry* pEntry, const Point& rPos)
+{
+ pImp->SetEntryPos( pEntry, rPos, FALSE, TRUE );
+}
+
+void SvIconView::SetEntryPos( SvLBoxEntry* pEntry, const Point& rPos, BOOL bAdjustAtGrid )
+{
+ pImp->SetEntryPos( pEntry, rPos, bAdjustAtGrid );
+}
+
+void SvIconView::SetFont( const Font& rFont )
+{
+ Font aTempFont( rFont );
+ aTempFont.SetTransparent( TRUE );
+ SvLBox::SetFont( aTempFont );
+ RecalcViewData();
+ pImp->ChangedFont();
+}
+
+void SvIconView::ViewDataInitialized( SvLBoxEntry* pEntry )
+{
+ pImp->ViewDataInitialized( pEntry );
+}
+
+SvLBoxEntry* SvIconView::GetCurEntry() const
+{
+ return pImp->GetCurEntry();
+}
+
+SvLBoxEntry* SvIconView::GetDropTarget( const Point& rPos )
+{
+ return pImp->GetDropTarget( rPos );
+}
+
+SvLBoxEntry* SvIconView::GetEntry( const Point& rPixPos, BOOL ) const
+{
+ Point aPos( rPixPos );
+ aPos -= GetMapMode().GetOrigin();
+ return ((SvIconView*)this)->pImp->GetEntry( aPos );
+}
+
+SvLBoxEntry* SvIconView::GetEntryFromLogicPos( const Point& rDocPos ) const
+{
+ return ((SvIconView*)this)->pImp->GetEntry( rDocPos );
+}
+
+
+void SvIconView::SetWindowBits( WinBits nWinStyle )
+{
+ nWinBits = nWinStyle;
+ pImp->SetWindowBits( nWinStyle );
+}
+
+void SvIconView::PaintEntry( SvLBoxEntry* pEntry )
+{
+ pImp->PaintEntry( pEntry );
+}
+
+
+void SvIconView::PaintEntry( SvLBoxEntry* pEntry, const Point& rPos )
+{
+ pImp->PaintEntry( pEntry, rPos );
+}
+
+Rectangle SvIconView::GetFocusRect( SvLBoxEntry* pEntry )
+{
+ return pImp->CalcFocusRect( pEntry );
+}
+
+void SvIconView::InvalidateEntry( SvLBoxEntry* pEntry )
+{
+ pImp->InvalidateEntry( pEntry );
+}
+
+void SvIconView::SetDragDropMode( DragDropMode nDDMode )
+{
+ SvLBox::SetDragDropMode( nDDMode );
+ pImp->SetDragDropMode( nDDMode );
+}
+
+void SvIconView::SetSelectionMode( SelectionMode eSelMode )
+{
+ SvLBox::SetSelectionMode( eSelMode );
+ pImp->SetSelectionMode( eSelMode );
+}
+
+BOOL SvIconView::Select( SvLBoxEntry* pEntry, BOOL bSelect )
+{
+ EndEditing();
+ BOOL bRetVal = SvListView::Select( pEntry, bSelect );
+ if( bRetVal )
+ {
+ pImp->EntrySelected( pEntry, bSelect );
+ pHdlEntry = pEntry;
+ SelectHdl();
+ }
+ return bRetVal;
+}
+
+void SvIconView::SelectAll( BOOL bSelect, BOOL bPaint )
+{
+ SvLBoxEntry* pEntry = pImp->GetCurParent();
+ pEntry = FirstChild( pEntry );
+ while( pEntry )
+ {
+ Select( pEntry, bSelect );
+ pEntry = NextSibling( pEntry );
+ }
+}
+
+void SvIconView::Arrange()
+{
+#ifdef DBG_UTIL
+ USHORT n=1;
+ if( n == 1 && n-1 == 0 )
+ {
+ pImp->Arrange();
+ }
+ else
+ {
+ pImp->AdjustAtGrid();
+ }
+#else
+ pImp->Arrange();
+#endif
+}
+
+
+void SvIconView::SetSpaceBetweenEntries( long nX, long nY )
+{
+ pImp->SetSpaceBetweenEntries( nX, nY );
+}
+
+BOOL SvIconView::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
+{
+ return pImp->NotifyMoving(pTarget,pEntry,rpNewParent,rNewChildPos);
+}
+
+BOOL SvIconView::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
+{
+ return pImp->NotifyCopying(pTarget,pEntry,rpNewParent,rNewChildPos);
+}
+
+
+void SvIconView::EnableInplaceEditing( BOOL bEnable )
+{
+ SvLBox::EnableInplaceEditing( bEnable );
+}
+
+void SvIconView::EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
+ const Point& )
+{
+ if ( pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
+ {
+ Selection aSel( SELECTION_MIN, SELECTION_MAX );
+ if ( EditingEntry( pEntry, aSel ) )
+ {
+ SelectAll( FALSE );
+ EditItemText( pEntry, (SvLBoxString*)pItem, aSel );
+ }
+ }
+}
+
+
+void SvIconView::EditItemText( SvLBoxEntry* pEntry, SvLBoxItem* pItem,
+ const Selection& rSel )
+{
+ DBG_ASSERT(pEntry&&pItem,"EditItemText:Params?")
+ pCurEdEntry = pEntry;
+ pCurEdItem = pItem;
+ Rectangle aRect( pImp->CalcTextRect( pEntry, (SvLBoxString*)pItem,0,TRUE ));
+
+ aRect.Bottom() += 4;
+ pImp->MakeVisible( aRect ); // vor der Umrechnung in Pixel-Koord. rufen!
+ aRect.Bottom() -= 4;
+
+ Point aPos( aRect.TopLeft() );
+ aPos += GetMapMode().GetOrigin(); // Dok-Koord. -> Window-Koord.
+ aRect.SetPos( aPos );
+
+ aRect.Bottom() += 2; // sieht huebscher aus
+
+#ifdef WIN
+ aRect.Bottom() += 4;
+#endif
+#ifdef OS2
+
+#if OS2_SINGLE_LINE_EDIT
+ aRect.Left() -= 3;
+ aRect.Right() += 3;
+ aRect.Top() -= 3;
+ aRect.Bottom() += 3;
+#else
+ aRect.Left() -= 10;
+ aRect.Right() += 10;
+ aRect.Top() -= 5;
+ aRect.Bottom() += 5;
+#endif
+
+#endif // OS2
+ EditText( ((SvLBoxString*)pItem)->GetText(), aRect, rSel, TRUE );
+}
+
+void SvIconView::EditEntry( SvLBoxEntry* pEntry )
+{
+ if( !pEntry )
+ pEntry = pImp->GetCurEntry();
+ if( pEntry )
+ {
+ SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if( pItem )
+ {
+ Selection aSel( SELECTION_MIN, SELECTION_MAX );
+ if( EditingEntry( pEntry, aSel ) )
+ {
+ SelectAll( FALSE );
+ EditItemText( pEntry, pItem, aSel );
+ }
+ }
+ }
+}
+
+void SvIconView::EditedText( const XubString& rStr )
+{
+ XubString aRefStr( ((SvLBoxString*)pCurEdItem)->GetText() );
+ if ( EditedEntry( pCurEdEntry, rStr ) )
+ {
+ ((SvLBoxString*)pCurEdItem)->SetText( pCurEdEntry, rStr );
+ pModel->InvalidateEntry( pCurEdEntry );
+ }
+ if( GetSelectionMode()==SINGLE_SELECTION && !GetSelectionCount())
+ Select( pCurEdEntry );
+}
+
+
+BOOL SvIconView::EditingEntry( SvLBoxEntry*, Selection& )
+{
+ return TRUE;
+}
+
+BOOL SvIconView::EditedEntry( SvLBoxEntry*, const XubString& )
+{
+ return TRUE;
+}
+
+
+void SvIconView::WriteDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo)
+{
+ pImp->WriteDragServerInfo( rPos, pInfo );
+}
+
+void SvIconView::ReadDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo )
+{
+ pImp->ReadDragServerInfo( rPos, pInfo );
+}
+
+void SvIconView::Command( const CommandEvent& rCEvt )
+{
+ pImp->Command( rCEvt );
+}
+
+void SvIconView::SetCurParent( SvLBoxEntry* pNewParent )
+{
+ if ( pNewParent && pNewParent->HasChildsOnDemand() )
+ RequestingChilds( pNewParent );
+ pImp->SetCurParent( pNewParent );
+}
+
+SvLBoxEntry* SvIconView::GetCurParent() const
+{
+ return pImp->GetCurParent();
+}
+
+SvViewData* SvIconView::CreateViewData( SvListEntry* pEntry )
+{
+ SvIcnVwDataEntry* pEntryData = new SvIcnVwDataEntry;
+ return (SvViewData*)pEntryData;
+}
+
+void SvIconView::InitViewData( SvViewData* pData, SvListEntry* pEntry )
+{
+ SvLBox::InitViewData( pData, pEntry );
+ pImp->InvalidateBoundingRect( ((SvIcnVwDataEntry*)pData)->aRect );
+}
+
+Region SvIconView::GetDragRegion() const
+{
+ Rectangle aRect;
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if( pEntry )
+ aRect = pImp->GetBoundingRect( pEntry );
+ Region aRegion( aRect );
+ return aRegion;
+}
+
+ULONG SvIconView::GetSelectionCount() const
+{
+ return (ULONG)(pImp->GetSelectionCount());
+}
+
+void SvIconView::SetGrid( long nDX, long nDY )
+{
+ pImp->SetGrid( nDX, nDY );
+}
+
+void SvIconView::ModelNotification( USHORT nActionId, SvListEntry* pEntry1,
+ SvListEntry* pEntry2, ULONG nPos )
+{
+ SvLBox::ModelNotification( nActionId, pEntry1, pEntry2, nPos );
+ switch( nActionId )
+ {
+ case LISTACTION_RESORTING:
+ SetUpdateMode( FALSE );
+ break;
+
+ case LISTACTION_RESORTED:
+ SetUpdateMode( TRUE );
+ Arrange();
+ break;
+
+ case LISTACTION_CLEARED:
+ if( IsUpdateMode() )
+ Update();
+ break;
+ }
+}
+
+
+void SvIconView::Scroll( long nDeltaX, long nDeltaY )
+{
+ pImp->Scroll( nDeltaX, nDeltaY, FALSE );
+}
+
+void SvIconView::PrepareCommandEvent( const CommandEvent& rCEvt )
+{
+ pImp->PrepareCommandEvent( rCEvt );
+}
+
+void SvIconView::BeginDrag( const Point& rPos )
+{
+ SvLBoxEntry* pEntry = GetEntry( rPos, TRUE );
+ pImp->pViewData = pEntry;
+ SvLBox::BeginDrag( rPos );
+}
+
+BOOL __EXPORT SvIconView::QueryDrop( DropEvent& rDEvt )
+{
+ if( pImp->pViewData )
+ {
+ pImp->HideDDIcon();
+ }
+ BOOL bResult = SvLBox::QueryDrop( rDEvt );
+ if( bResult )
+ {
+ pImp->ShowDDIcon( pImp->pViewData, rDEvt.GetPosPixel() );
+ }
+ return bResult;
+}
+
+BOOL SvIconView::Drop( const DropEvent& rDEvt )
+{
+ if( pImp->pViewData )
+ {
+ pImp->HideDDIcon();
+ pImp->pViewData = 0;
+ }
+ return SvLBox::Drop( rDEvt );
+}
+
+void SvIconView::ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos )
+{
+ pImp->ShowDDIcon( pRefEntry, rPos );
+}
+
+void SvIconView::HideDDIcon()
+{
+ pImp->HideDDIcon();
+}
+
+void SvIconView::HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPos )
+{
+ pImp->HideShowDDIcon( pRefEntry, rPos );
+}
+
+void SvIconView::SelectRect( const Rectangle& rRect, BOOL bAdd,
+ SvPtrarr* pRects, short nOffs )
+{
+ pImp->SelectRect( rRect, bAdd, pRects, nOffs );
+}
+
+void SvIconView::CalcScrollOffsets( const Point& rRefPosPixel, long& rX, long& rY,
+ BOOL b, USHORT nBorderWidth )
+{
+ pImp->CalcScrollOffsets( rRefPosPixel, rX, rY, b, nBorderWidth );
+}
+
+void SvIconView::EndTracking()
+{
+ pImp->EndTracking();
+}
+
+void SvIconView::MakeVisible( SvLBoxEntry* pEntry )
+{
+ pImp->MakeVisible( pEntry );
+}
+
+void SvIconView::PreparePaint( SvLBoxEntry* )
+{
+}
+
+void SvIconView::AdjustAtGrid( SvLBoxEntry* pEntry )
+{
+ pImp->AdjustAtGrid( pEntry );
+}
+
+void SvIconView::LockEntryPos( SvLBoxEntry* pEntry, BOOL bLock )
+{
+ SvIcnVwDataEntry* pViewData = (SvIcnVwDataEntry*)GetViewData( pEntry );
+ if( bLock )
+ pViewData->SetVwFlags( ICNVW_FLAG_POS_LOCKED );
+ else
+ pViewData->ClearVwFlags( ICNVW_FLAG_POS_LOCKED );
+}
+
+BOOL SvIconView::IsEntryPosLocked( const SvLBoxEntry* pEntry ) const
+{
+ const SvIcnVwDataEntry* pViewData = (const SvIcnVwDataEntry*)GetViewData( (SvListEntry*)pEntry );
+ return pViewData->IsEntryPosLocked();
+}
+
+void SvIconView::SetTextMode( SvIconViewTextMode eMode, SvLBoxEntry* pEntry )
+{
+ pImp->SetTextMode( eMode, pEntry );
+}
+
+SvIconViewTextMode SvIconView::GetTextMode( const SvLBoxEntry* pEntry ) const
+{
+ return pImp->GetTextMode( pEntry );
+}
+
+SvLBoxEntry* SvIconView::GetNextEntry( const Point& rPixPos, SvLBoxEntry* pCurEntry, BOOL ) const
+{
+ Point aPos( rPixPos );
+ aPos -= GetMapMode().GetOrigin();
+ return ((SvIconView*)this)->pImp->GetNextEntry( aPos, pCurEntry );
+}
+
+SvLBoxEntry* SvIconView::GetPrevEntry( const Point& rPixPos, SvLBoxEntry* pCurEntry, BOOL ) const
+{
+ Point aPos( rPixPos );
+ aPos -= GetMapMode().GetOrigin();
+ return ((SvIconView*)this)->pImp->GetPrevEntry( aPos, pCurEntry );
+}
+
+void SvIconView::ShowFocusRect( const SvLBoxEntry* pEntry )
+{
+ pImp->ShowFocusRect( pEntry );
+}
+
+
diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx
new file mode 100644
index 000000000000..ebdc765651cf
--- /dev/null
+++ b/svtools/source/contnr/svimpbox.cxx
@@ -0,0 +1,3171 @@
+/*************************************************************************
+ *
+ * $RCSfile: svimpbox.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _SV_SVAPP_HXX //autogen
+#include <vcl/svapp.hxx>
+#endif
+
+#ifndef _HELP_HXX
+#include <vcl/help.hxx>
+#endif
+#ifndef _TABBAR_HXX
+#include <tabbar.hxx>
+#endif
+
+#pragma hdrstop
+
+#define _SVTREEBX_CXX
+#include <svtreebx.hxx>
+#ifndef _SVLBOX_HXX
+#include <svlbox.hxx>
+#endif
+#include <svimpbox.hxx>
+
+
+#define NODE_BMP_TABDIST_NOTVALID -2000000
+
+SvImpLBox::SvImpLBox( SvTreeListBox* pLBView, SvLBoxTreeList* pLBTree, WinBits nWinStyle) :
+ aVerSBar( pLBView, WB_DRAG | WB_VSCROLL ),
+ aHorSBar( pLBView, WB_DRAG | WB_HSCROLL ),
+ aScrBarBox( pLBView ),
+ aOutputSize( 0,0 ),
+ aSelEng( pLBView, (FunctionSet*)0 ),
+ aFctSet( this, &aSelEng, pLBView ),
+ pTabBar(0)
+{
+ pView = pLBView;
+ pTree = pLBTree;
+ aSelEng.SetFunctionSet( (FunctionSet*)&aFctSet );
+ aSelEng.ExpandSelectionOnMouseMove( FALSE );
+ SetWindowBits( nWinStyle );
+ SetSelectionMode( SINGLE_SELECTION );
+ SetDragDropMode( 0 );
+
+ aVerSBar.SetScrollHdl( LINK( this, SvImpLBox, ScrollUpDownHdl ) );
+ aHorSBar.SetScrollHdl( LINK( this, SvImpLBox, ScrollLeftRightHdl ) );
+ aHorSBar.SetEndScrollHdl( LINK( this, SvImpLBox, EndScrollHdl ) );
+ aVerSBar.SetEndScrollHdl( LINK( this, SvImpLBox, EndScrollHdl ) );
+#if SUPD > 358
+ aVerSBar.SetRange( Range(0,0) );
+ aVerSBar.Hide();
+#endif
+ aHorSBar.SetRange( Range(0,0) );
+ aHorSBar.SetPageSize( 24 ); // Pixel
+ aHorSBar.SetLineSize( 8 ); // Pixel
+
+ nHorSBarHeight = (short)aHorSBar.GetSizePixel().Height();
+ nVerSBarWidth = (short)aVerSBar.GetSizePixel().Width();
+
+ pStartEntry = 0;
+ pCursor = 0;
+ pAnchor = 0;
+ nVisibleCount = 0; // Anzahl Daten-Zeilen im Control
+ nNodeBmpTabDistance = NODE_BMP_TABDIST_NOTVALID;
+ nYoffsNodeBmp = 0;
+ nNodeBmpWidth = 0;
+
+ bAsyncBeginDrag = FALSE;
+ aAsyncBeginDragTimer.SetTimeout( 0 );
+ aAsyncBeginDragTimer.SetTimeoutHdl( LINK(this,SvImpLBox,BeginDragHdl));
+ // Button-Animation in Listbox
+ pActiveButton = 0;
+ pActiveEntry = 0;
+ pActiveTab = 0;
+
+ nFlags = 0;
+
+ aEditTimer.SetTimeout( 800 );
+ aEditTimer.SetTimeoutHdl( LINK(this,SvImpLBox,EditTimerCall) );
+
+ nMostRight = -1;
+ pMostRightEntry = 0;
+ nCurUserEvent = 0xffffffff;
+
+ bUpdateMode = TRUE;
+ bInVScrollHdl = FALSE;
+ nFlags |= F_FILLING;
+}
+
+SvImpLBox::~SvImpLBox()
+{
+ aEditTimer.Stop();
+ StopUserEvent();
+}
+
+void SvImpLBox::SetWindowBits( WinBits nWinStyle )
+{
+ nWinBits = nWinStyle;
+ if((nWinStyle & WB_SIMPLEMODE) && aSelEng.GetSelectionMode()==MULTIPLE_SELECTION)
+ aSelEng.AddAlways( TRUE );
+}
+
+// Das Model darf hier nicht mehr angefasst werden
+void SvImpLBox::Clear()
+{
+ StopUserEvent();
+ pStartEntry = 0;
+ pAnchor = 0;
+
+ pActiveButton = 0;
+ pActiveEntry = 0;
+ pActiveTab = 0;
+
+ nMostRight = -1;
+ pMostRightEntry = 0;
+
+ // Der Cursor darf hier nicht mehr angefasst werden!
+ if( pCursor )
+ {
+ if( pView->HasFocus() )
+ pView->HideFocus();
+ pCursor = 0;
+ }
+ aVerSBar.Hide();
+ aVerSBar.SetThumbPos( 0 );
+ Range aRange( 0, 0 );
+ aVerSBar.SetRange( aRange );
+ aOutputSize = pView->Control::GetOutputSizePixel();
+ nFlags &= ~(F_VER_SBARSIZE_WITH_HBAR | F_HOR_SBARSIZE_WITH_VBAR );
+ if( pTabBar )
+ {
+ aOutputSize.Height() -= nHorSBarHeight;
+ nFlags |= F_VER_SBARSIZE_WITH_HBAR;
+ }
+ if( !pTabBar )
+ aHorSBar.Hide();
+ aHorSBar.SetThumbPos( 0 );
+ MapMode aMapMode( pView->GetMapMode());
+ aMapMode.SetOrigin( Point(0,0) );
+ pView->Control::SetMapMode( aMapMode );
+ aHorSBar.SetRange( aRange );
+ aHorSBar.SetSizePixel(Size(aOutputSize.Width(),nHorSBarHeight));
+ pView->SetClipRegion();
+ if( GetUpdateMode() )
+ pView->Invalidate( GetVisibleArea() );
+ nFlags |= F_FILLING;
+ if( !aHorSBar.IsVisible() && !aVerSBar.IsVisible() )
+ aScrBarBox.Hide();
+}
+
+// *********************************************************************
+// Painten, Navigieren, Scrollen
+// *********************************************************************
+
+IMPL_LINK_INLINE_START( SvImpLBox, EndScrollHdl, ScrollBar *, pScrollBar )
+{
+ if( nFlags & F_ENDSCROLL_SET_VIS_SIZE )
+ {
+ aVerSBar.SetVisibleSize( nNextVerVisSize );
+ nFlags &= ~F_ENDSCROLL_SET_VIS_SIZE;
+ }
+ EndScroll();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvImpLBox, EndScrollHdl, ScrollBar *, pScrollBar )
+
+
+// Handler vertikale ScrollBar
+
+IMPL_LINK( SvImpLBox, ScrollUpDownHdl, ScrollBar *, pScrollBar )
+{
+ DBG_ASSERT(!bInVScrollHdl,"Scroll-Handler ueberholt sich!");
+ long nDelta = pScrollBar->GetDelta();
+ if( !nDelta )
+ return 0;
+
+ nFlags &= (~F_FILLING);
+
+ bInVScrollHdl = TRUE;
+
+ if( pView->IsEditingActive() )
+ {
+ pView->EndEditing( TRUE ); // Cancel
+ pView->Update();
+ }
+ BeginScroll();
+
+ if( nDelta > 0 )
+ {
+ if( nDelta == 1 )
+ CursorDown();
+ else
+ PageDown( (USHORT) nDelta );
+ }
+ else
+ {
+ nDelta *= (-1);
+ if( nDelta == 1 )
+ CursorUp();
+ else
+ PageUp( (USHORT) nDelta );
+ }
+ bInVScrollHdl = FALSE;
+ return 0;
+}
+
+
+void SvImpLBox::CursorDown()
+{
+ SvLBoxEntry* pNextFirstToDraw = (SvLBoxEntry*)(pView->NextVisible( pStartEntry));
+ if( pNextFirstToDraw )
+ {
+ nFlags &= (~F_FILLING);
+ pView->NotifyScrolling( -1 );
+ ShowCursor( FALSE );
+ pView->Update();
+ pStartEntry = pNextFirstToDraw;
+ Rectangle aArea( GetVisibleArea() );
+ pView->Scroll( 0, -(pView->GetEntryHeight()), aArea, SCROLL_NOCHILDREN );
+ pView->Update();
+ ShowCursor( TRUE );
+ pView->NotifyScrolled();
+ }
+}
+
+void SvImpLBox::CursorUp()
+{
+ SvLBoxEntry* pPrevFirstToDraw = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry));
+ if( pPrevFirstToDraw )
+ {
+ nFlags &= (~F_FILLING);
+ long nEntryHeight = pView->GetEntryHeight();
+ pView->NotifyScrolling( 1 );
+ ShowCursor( FALSE );
+ pView->Update();
+ pStartEntry = pPrevFirstToDraw;
+ Rectangle aArea( GetVisibleArea() );
+ aArea.Bottom() -= nEntryHeight;
+ pView->Scroll( 0, nEntryHeight, aArea, SCROLL_NOCHILDREN );
+ pView->Update();
+ ShowCursor( TRUE );
+ pView->NotifyScrolled();
+ }
+}
+
+void SvImpLBox::PageDown( USHORT nDelta )
+{
+ USHORT nRealDelta = nDelta;
+
+ if( !nDelta )
+ return;
+
+ SvLBoxEntry* pNext;
+ pNext = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nRealDelta ));
+ if( (ULONG)pNext == (ULONG)pStartEntry )
+ return;
+
+ ShowCursor( FALSE );
+
+ nFlags &= (~F_FILLING);
+ pView->Update();
+ pStartEntry = pNext;
+
+ if( nRealDelta >= nVisibleCount )
+ {
+ pView->Invalidate( GetVisibleArea() );
+ pView->Update();
+ }
+ else
+ {
+ long nScroll = nRealDelta * (-1);
+ pView->NotifyScrolling( nScroll );
+ Rectangle aArea( GetVisibleArea() );
+ nScroll = pView->GetEntryHeight()*nRealDelta;
+ nScroll = -nScroll;
+ pView->Update();
+ pView->Scroll( 0, nScroll, aArea, SCROLL_NOCHILDREN );
+ pView->Update();
+ pView->NotifyScrolled();
+ }
+
+ ShowCursor( TRUE );
+}
+
+void SvImpLBox::PageUp( USHORT nDelta )
+{
+ USHORT nRealDelta = nDelta;
+ if( !nDelta )
+ return;
+
+ SvLBoxEntry* pPrev = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry, nRealDelta ));
+ if( (ULONG)pPrev == (ULONG)pStartEntry )
+ return;
+
+ nFlags &= (~F_FILLING);
+ ShowCursor( FALSE );
+
+ pView->Update();
+ pStartEntry = pPrev;
+ if( nRealDelta >= nVisibleCount )
+ {
+ pView->Invalidate( GetVisibleArea() );
+ pView->Update();
+ }
+ else
+ {
+ long nEntryHeight = pView->GetEntryHeight();
+ pView->NotifyScrolling( (long)nRealDelta );
+ Rectangle aArea( GetVisibleArea() );
+ pView->Update();
+ pView->Scroll( 0, nEntryHeight*nRealDelta, aArea, SCROLL_NOCHILDREN );
+ pView->Update();
+ pView->NotifyScrolled();
+ }
+
+ ShowCursor( TRUE );
+}
+
+void SvImpLBox::KeyUp( BOOL bPageUp, BOOL bNotifyScroll )
+{
+ if( !aVerSBar.IsVisible() )
+ return;
+
+ long nDelta;
+ if( bPageUp )
+ nDelta = aVerSBar.GetPageSize();
+ else
+ nDelta = 1;
+
+ long nThumbPos = aVerSBar.GetThumbPos();
+
+ if( nThumbPos < nDelta )
+ nDelta = nThumbPos;
+
+ if( nDelta <= 0 )
+ return;
+
+ nFlags &= (~F_FILLING);
+ if( bNotifyScroll )
+ BeginScroll();
+
+ aVerSBar.SetThumbPos( nThumbPos - nDelta );
+ if( bPageUp )
+ PageUp( (short)nDelta );
+ else
+ CursorUp();
+
+ if( bNotifyScroll )
+ EndScroll();
+}
+
+
+void SvImpLBox::KeyDown( BOOL bPageDown, BOOL bNotifyScroll )
+{
+ if( !aVerSBar.IsVisible() )
+ return;
+
+ long nDelta;
+ if( bPageDown )
+ nDelta = aVerSBar.GetPageSize();
+ else
+ nDelta = 1;
+
+ long nThumbPos = aVerSBar.GetThumbPos();
+ long nVisibleSize = aVerSBar.GetVisibleSize();
+ long nRange = aVerSBar.GetRange().Len();
+
+ long nTmp = nThumbPos+nVisibleSize;
+ while( (nDelta > 0) && (nTmp+nDelta) >= nRange )
+ nDelta--;
+
+ if( nDelta <= 0 )
+ return;
+
+ nFlags &= (~F_FILLING);
+ if( bNotifyScroll )
+ BeginScroll();
+
+ aVerSBar.SetThumbPos( nThumbPos+nDelta );
+ if( bPageDown )
+ PageDown( (short)nDelta );
+ else
+ CursorDown();
+
+ if( bNotifyScroll )
+ EndScroll();
+}
+
+
+
+void SvImpLBox::InvalidateEntriesFrom( long nY ) const
+{
+ if( !(nFlags & F_IN_PAINT ))
+ {
+ Rectangle aRect( GetVisibleArea() );
+ aRect.Top() = nY;
+ pView->Invalidate( aRect );
+ }
+}
+
+void SvImpLBox::InvalidateEntry( long nY ) const
+{
+ if( !(nFlags & F_IN_PAINT ))
+ {
+ Rectangle aRect( GetVisibleArea() );
+ long nMaxBottom = aRect.Bottom();
+ aRect.Top() = nY;
+ aRect.Bottom() = nY; aRect.Bottom() += pView->GetEntryHeight();
+ if( aRect.Top() > nMaxBottom )
+ return;
+ if( aRect.Bottom() > nMaxBottom )
+ aRect.Bottom() = nMaxBottom;
+ pView->Invalidate( aRect );
+ }
+}
+
+void SvImpLBox::InvalidateEntry( SvLBoxEntry* pEntry )
+{
+ if( GetUpdateMode() )
+ {
+ long nPrev = nMostRight;
+ SetMostRight( pEntry );
+ if( nPrev < nMostRight )
+ ShowVerSBar();
+ }
+ if( !(nFlags & F_IN_PAINT ))
+ {
+ BOOL bHasFocusRect = FALSE;
+ if( pEntry==pCursor && pView->HasFocus() )
+ {
+ bHasFocusRect = TRUE;
+ ShowCursor( FALSE );
+ }
+ InvalidateEntry( GetEntryLine( pEntry ) );
+ if( bHasFocusRect )
+ ShowCursor( TRUE );
+ }
+}
+
+
+void SvImpLBox::RecalcFocusRect()
+{
+ if( pView->HasFocus() && pCursor )
+ {
+ pView->HideFocus();
+ long nY = GetEntryLine( pCursor );
+ Rectangle aRect = pView->GetFocusRect( pCursor, nY );
+ Region aOldClip( pView->GetClipRegion());
+ Region aClipRegion( GetClipRegionRect() );
+ pView->SetClipRegion( aClipRegion );
+ pView->ShowFocus( aRect );
+ pView->SetClipRegion( aOldClip );
+ }
+}
+
+//
+// Setzt Cursor. Passt bei SingleSelection die Selektion an
+//
+
+void SvImpLBox::SetCursor( SvLBoxEntry* pEntry, BOOL bForceNoSelect )
+{
+ SvViewDataEntry* pViewDataNewCur = 0;
+ if( pEntry )
+ pViewDataNewCur= pView->GetViewDataEntry(pEntry);
+ if( pEntry &&
+ pEntry == pCursor &&
+ pViewDataNewCur->HasFocus() &&
+ pViewDataNewCur->IsSelected())
+ {
+ return;
+ }
+ SvLBoxEntry* pOldCursor = pCursor;
+ if( pCursor && pEntry != pCursor )
+ {
+ pView->SetEntryFocus( pCursor, FALSE );
+ if( bSimpleTravel )
+ pView->Select( pCursor, FALSE );
+ pView->HideFocus();
+ }
+ pCursor = pEntry;
+ if( pCursor )
+ {
+ pViewDataNewCur->SetFocus( TRUE );
+ if(!bForceNoSelect && bSimpleTravel && !(nFlags & F_DESEL_ALL) && GetUpdateMode())
+ {
+ pView->Select( pCursor, TRUE );
+ }
+ // Mehrfachselektion: Im Cursor-Move selektieren, wenn
+ // nicht im Add-Mode (Ctrl-F8)
+ else if( GetUpdateMode() &&
+ pView->GetSelectionMode() == MULTIPLE_SELECTION &&
+ !(nFlags & F_DESEL_ALL) && !aSelEng.IsAddMode() &&
+ !bForceNoSelect )
+ {
+ pView->Select( pCursor, TRUE );
+ }
+ else
+ {
+ ShowCursor( TRUE );
+ }
+
+ if( pAnchor )
+ {
+ DBG_ASSERT(aSelEng.GetSelectionMode() != SINGLE_SELECTION,"Mode?")
+ SetAnchorSelection( pOldCursor, pCursor );
+ }
+ }
+ nFlags &= (~F_DESEL_ALL);
+}
+
+void SvImpLBox::ShowCursor( BOOL bShow )
+{
+ if( !bShow || !pCursor || !pView->HasFocus() )
+ pView->HideFocus();
+ else
+ {
+ long nY = GetEntryLine( pCursor );
+ Rectangle aRect = pView->GetFocusRect( pCursor, nY );
+ Region aOldClip( pView->GetClipRegion());
+ Region aClipRegion( GetClipRegionRect() );
+ pView->SetClipRegion( aClipRegion );
+ pView->ShowFocus( aRect );
+ pView->SetClipRegion( aOldClip );
+ }
+}
+
+
+
+void SvImpLBox::UpdateAll( BOOL bInvalidateCompleteView,
+ BOOL bUpdateVerScrollBar )
+{
+ if( bUpdateVerScrollBar )
+ FindMostRight(0);
+ aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
+ SyncVerThumb();
+ FillView();
+ ShowVerSBar();
+ if( bSimpleTravel && pCursor && pView->HasFocus() )
+ pView->Select( pCursor, TRUE );
+ ShowCursor( TRUE );
+ if( bInvalidateCompleteView )
+ pView->Invalidate();
+ else
+ pView->Invalidate( GetVisibleArea() );
+}
+
+IMPL_LINK_INLINE_START( SvImpLBox, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
+{
+ long nDelta = pScrollBar->GetDelta();
+ if( nDelta )
+ {
+ if( pView->IsEditingActive() )
+ {
+ pView->EndEditing( TRUE ); // Cancel
+ pView->Update();
+ }
+ pView->nFocusWidth = -1;
+ KeyLeftRight( nDelta );
+ }
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvImpLBox, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
+
+void SvImpLBox::KeyLeftRight( long nDelta )
+{
+ if( !(nFlags & F_IN_RESIZE) )
+ pView->Update();
+ BeginScroll();
+ nFlags &= (~F_FILLING);
+ pView->NotifyScrolling( 0 ); // 0 == horizontales Scrolling
+ ShowCursor( FALSE );
+
+ // neuen Origin berechnen
+ long nPos = aHorSBar.GetThumbPos();
+ Point aOrigin( -nPos, 0 );
+
+ MapMode aMapMode( pView->GetMapMode() );
+ aMapMode.SetOrigin( aOrigin );
+ pView->SetMapMode( aMapMode );
+
+ if( !(nFlags & F_IN_RESIZE) )
+ {
+ Rectangle aRect( GetVisibleArea() );
+ pView->Scroll( -nDelta, 0, aRect, SCROLL_NOCHILDREN );
+ }
+ else
+ pView->Invalidate();
+ RecalcFocusRect();
+ ShowCursor( TRUE );
+ pView->NotifyScrolled();
+}
+
+
+// gibt letzten Eintrag zurueck, wenn Position unter
+// dem letzten Eintrag ist
+SvLBoxEntry* SvImpLBox::GetClickedEntry( const Point& rPoint ) const
+{
+ if( pView->GetEntryCount() == 0 || !pStartEntry)
+ return 0;
+
+ USHORT nClickedEntry = (USHORT)(rPoint.Y() / pView->GetEntryHeight() );
+ USHORT nTemp = nClickedEntry;
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nTemp ));
+ return pEntry;
+}
+
+//
+// prueft, ob der Eintrag "richtig" getroffen wurde
+// (Focusrect+ ContextBitmap bei TreeListBox)
+//
+BOOL SvImpLBox::EntryReallyHit(SvLBoxEntry* pEntry,const Point& rPosPixel,long nLine)
+{
+ BOOL bRet;
+ // bei "besonderen" Entries (mit CheckButtons usw.) sind wir
+ // nicht so pingelig
+ if( pEntry->ItemCount() >= 3 )
+ return TRUE;
+
+ Rectangle aRect( pView->GetFocusRect( pEntry, nLine ));
+ if( pView->IsA() == SV_LISTBOX_ID_TREEBOX )
+ {
+ SvLBoxContextBmp* pBmp = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ aRect.Left() -= pBmp->GetSize(pView,pEntry).Width();
+ aRect.Left() -= 4; // etwas Speilraum lassen
+ }
+ Point aPos( rPosPixel );
+ aPos -= pView->GetMapMode().GetOrigin();
+ if( aRect.IsInside( aPos ) )
+ bRet = TRUE;
+ else
+ bRet = FALSE;
+ return bRet;
+}
+
+
+// gibt 0 zurueck, wenn Position unter dem letzten Eintrag ist
+SvLBoxEntry* SvImpLBox::GetEntry( const Point& rPoint ) const
+{
+ if( (pView->GetEntryCount() == 0) || !pStartEntry ||
+ (rPoint.Y() > aOutputSize.Height()) )
+ return 0;
+
+ USHORT nClickedEntry = (USHORT)(rPoint.Y() / pView->GetEntryHeight() );
+ USHORT nTemp = nClickedEntry;
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nTemp ));
+ if( nTemp != nClickedEntry )
+ pEntry = 0;
+ return pEntry;
+}
+
+
+SvLBoxEntry* SvImpLBox::MakePointVisible(const Point& rPoint,BOOL bNotifyScroll)
+{
+ if( !pCursor )
+ return 0;
+ long nY = rPoint.Y();
+ SvLBoxEntry* pEntry = 0;
+ long nMax = aOutputSize.Height();
+ if( nY < 0 || nY >= nMax ) // aOutputSize.Height() )
+ {
+ if( nY < 0 )
+ pEntry = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
+ else
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pCursor ));
+
+ if( pEntry && pEntry != pCursor )
+ pView->SetEntryFocus( pCursor, FALSE );
+
+ if( nY < 0 )
+ KeyUp( FALSE, bNotifyScroll );
+ else
+ KeyDown( FALSE, bNotifyScroll );
+ }
+ else
+ {
+ pEntry = GetClickedEntry( rPoint );
+ if( !pEntry )
+ {
+ USHORT nSteps = 0xFFFF;
+ // LastVisible ist noch nicht implementiert!
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry, nSteps ));
+ }
+ if( pEntry )
+ {
+ if( pEntry != pCursor &&
+ aSelEng.GetSelectionMode() == SINGLE_SELECTION
+ )
+ pView->Select( pCursor, FALSE );
+ }
+ }
+ return pEntry;
+}
+
+Rectangle SvImpLBox::GetClipRegionRect() const
+{
+ Point aOrigin( pView->GetMapMode().GetOrigin() );
+ aOrigin.X() *= -1; // Umrechnung Dokumentkoord.
+ Rectangle aClipRect( aOrigin, aOutputSize );
+ aClipRect.Bottom()++;
+ return aClipRect;
+}
+
+
+void SvImpLBox::Paint( const Rectangle& rRect )
+{
+ if( !pView->GetVisibleCount() )
+ return;
+
+ nFlags |= F_IN_PAINT;
+
+//#if SUPD > 364
+ if( nFlags & F_FILLING )
+ {
+ SvLBoxEntry* pFirst = pView->First();
+ if( pFirst != pStartEntry )
+ {
+ ShowCursor( FALSE );
+ pStartEntry = pView->First();
+ aVerSBar.SetThumbPos( 0 );
+ StopUserEvent();
+ ShowCursor( TRUE );
+ nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpLBox,MyUserEvent),(void*)1);
+ return;
+ }
+ }
+//#endif
+
+ if( !pStartEntry )
+ {
+ pStartEntry = pView->First();
+ }
+
+#ifdef XX_OV
+ ULONG nXAbsPos = (USHORT)pTree->GetAbsPos( pStartEntry );
+ ULONG nXVisPos = pView->GetVisiblePos( pStartEntry );
+ SvLBoxString* pXStr = (SvLBoxString*)pStartEntry->GetFirstItem( SV_ITEM_ID_LBOXSTRING);
+#endif
+
+
+
+ if( nNodeBmpTabDistance == NODE_BMP_TABDIST_NOTVALID )
+ SetNodeBmpTabDistance();
+
+ long nRectHeight = rRect.GetHeight();
+ long nEntryHeight = pView->GetEntryHeight();
+
+ int bHorSBar;
+ if( (pView->nWindowStyle) & WB_HSCROLL )
+ bHorSBar = TRUE;
+ else
+ bHorSBar = FALSE;
+
+ // Bereich der zu zeichnenden Entries berechnen
+ USHORT nStartLine = (USHORT)( rRect.Top() / nEntryHeight );
+ USHORT nCount = (USHORT)( nRectHeight / nEntryHeight );
+ nCount += 2; // keine Zeile vergessen
+
+ long nY = nStartLine * nEntryHeight;
+ SvLBoxEntry* pEntry = pStartEntry;
+ while( nStartLine && pEntry )
+ {
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ nStartLine--;
+ }
+
+ Region aClipRegion( GetClipRegionRect() );
+
+ // erst die Linien Zeichnen, dann clippen!
+ pView->SetClipRegion();
+ if( nWinBits & ( WB_HASLINES | WB_HASLINESATROOT ) )
+ DrawNet();
+
+ pView->SetClipRegion( aClipRegion );
+
+ for( USHORT n=0; n< nCount && pEntry; n++ )
+ {
+ /*long nMaxRight=*/
+ pView->PaintEntry1( pEntry, nY, 0xffff, TRUE );
+ nY += nEntryHeight;
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+
+ if( !pCursor )
+ {
+ if( aSelEng.GetSelectionMode()==SINGLE_SELECTION )
+ {
+ if( nWinBits & WB_NOINITIALSELECTION )
+ {
+ // nicht selektieren
+ SetCursor( pStartEntry, TRUE );
+ }
+ else
+ SetCursor( pStartEntry );
+ }
+ else
+ // nicht selektieren
+ SetCursor( pStartEntry, TRUE );
+ //OV, 16.7.97, warum HideFocus?? (siehe Bugid 41404)
+ //pView->HideFocus();
+ }
+ nFlags &= (~F_DESEL_ALL);
+
+ pView->SetClipRegion();
+ Rectangle aRect;
+ if( !(nFlags & F_PAINTED) )
+ {
+ nFlags |= F_PAINTED;
+ RepaintScrollBars();
+ }
+ nFlags &= (~F_IN_PAINT);
+}
+
+void SvImpLBox::MakeVisible( SvLBoxEntry* pEntry, BOOL bMoveToTop )
+{
+ if( !pEntry )
+ return;
+
+ BOOL bInView = IsEntryInView( pEntry );
+
+ if( bInView && (!bMoveToTop || pStartEntry == pEntry) )
+ return; // ist schon sichtbar
+
+ if( pStartEntry || (nWinBits & WB_FORCE_MAKEVISIBLE) )
+ nFlags &= (~F_FILLING);
+ if( !bInView )
+ {
+ if( !pView->IsEntryVisible(pEntry) ) // Parent(s) zugeklappt ?
+ {
+ SvLBoxEntry* pParent = pView->GetParent( pEntry );
+ while( pParent )
+ {
+ if( !pView->IsExpanded( pParent ) )
+ {
+ BOOL bRet = pView->Expand( pParent );
+ DBG_ASSERT(bRet,"Not expanded!");
+ }
+ pParent = pView->GetParent( pParent );
+ }
+ // Passen Childs der Parents in View oder muessen wir scrollen ?
+ if( IsEntryInView( pEntry ) && !bMoveToTop )
+ return; // Scrollen nicht noetig -> tschuess
+ }
+ }
+
+ pStartEntry = pEntry;
+ ShowCursor( FALSE );
+ FillView();
+ aVerSBar.SetThumbPos( (long)(pView->GetVisiblePos( pStartEntry )) );
+ ShowCursor( TRUE );
+ pView->Invalidate();
+}
+
+
+void SvImpLBox::RepaintSelectionItems()
+{
+ if( !pView->GetVisibleCount() )
+ return;
+
+ if( !pStartEntry )
+ pStartEntry = pView->First();
+
+ if( nNodeBmpTabDistance == NODE_BMP_TABDIST_NOTVALID )
+ SetNodeBmpTabDistance();
+
+ ShowCursor( FALSE );
+
+ long nEntryHeight = pView->GetEntryHeight();
+
+ USHORT nCount = nVisibleCount;
+ long nY = 0;
+ SvLBoxEntry* pEntry = pStartEntry;
+ for( USHORT n=0; n< nCount && pEntry; n++ )
+ {
+ pView->PaintEntry1( pEntry, nY, 0xffff ); //wg. ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
+ nY += nEntryHeight;
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+
+ ShowCursor( TRUE );
+}
+
+
+void SvImpLBox::DrawNet()
+{
+ if( pView->GetVisibleCount() < 2 && !pStartEntry->HasChildsOnDemand() &&
+ !pStartEntry->HasChilds() )
+ return;
+ long nEntryHeight = pView->GetEntryHeight();
+ long nEntryHeightDIV2 = nEntryHeight / 2;
+ if( nEntryHeightDIV2 && !(nEntryHeight & 0x0001))
+ nEntryHeightDIV2--;
+
+ SvLBoxEntry* pChild;
+ SvLBoxEntry* pEntry = pStartEntry;
+
+ SvLBoxTab* pFirstDynamicTab = pView->GetFirstDynamicTab();
+ while( pTree->GetDepth( pEntry ) > 0 )
+ pEntry = pView->GetParent( pEntry );
+ USHORT nOffs = (USHORT)(pView->GetVisiblePos( pStartEntry ) -
+ pView->GetVisiblePos( pEntry ));
+ long nY = 0;
+ nY -= ( nOffs * nEntryHeight );
+
+ DBG_ASSERT(pFirstDynamicTab,"No Tree!")
+
+ Color aOldLineColor = pView->GetLineColor();
+ const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings();
+ Color aCol= rStyleSettings.GetFaceColor();
+
+ if( aCol.IsRGBEqual( pView->GetBackground().GetColor()) )
+ aCol = rStyleSettings.GetShadowColor();
+ pView->SetLineColor( aCol );
+ Point aPos1, aPos2;
+ USHORT nDistance;
+ USHORT nMax = nVisibleCount + nOffs + 1;
+ for( USHORT n=0; n< nMax && pEntry; n++ )
+ {
+ if( pView->IsExpanded(pEntry) )
+ {
+ aPos1.X() = pView->GetTabPos(pEntry, pFirstDynamicTab);
+ // wenn keine ContextBitmap, dann etwas nach rechts
+ // unter den ersten Text (Node.Bmp ebenfalls
+ if( !pView->nContextBmpWidthMax )
+ aPos1.X() += aExpNodeBmp.GetSizePixel().Width() / 2;
+
+ aPos1.Y() = nY;
+ aPos1.Y() += nEntryHeightDIV2;
+
+ pChild = pView->FirstChild( pEntry );
+ DBG_ASSERT(pChild,"Child?")
+ pChild = pTree->LastSibling( pChild );
+ nDistance = (USHORT)(pView->GetVisiblePos(pChild) -
+ pView->GetVisiblePos(pEntry));
+ aPos2 = aPos1;
+ aPos2.Y() += nDistance * nEntryHeight;
+ pView->DrawLine( aPos1, aPos2 );
+ }
+ // Sichtbar im Control ?
+ if( n>= nOffs && ((nWinBits & WB_HASLINESATROOT) || !pTree->IsAtRootDepth(pEntry)))
+ {
+ // kann aPos1 recyclet werden ?
+ if( !pView->IsExpanded(pEntry) )
+ {
+ // njet
+ aPos1.X() = pView->GetTabPos(pEntry, pFirstDynamicTab);
+ // wenn keine ContextBitmap, dann etwas nach rechts
+ // unter den ersten Text (Node.Bmp ebenfalls
+ if( !pView->nContextBmpWidthMax )
+ aPos1.X() += aExpNodeBmp.GetSizePixel().Width() / 2;
+ aPos1.Y() = nY;
+ aPos1.Y() += nEntryHeightDIV2;
+ aPos2.X() = aPos1.X();
+ }
+ aPos2.Y() = aPos1.Y();
+ aPos2.X() -= pView->GetIndent();
+ pView->DrawLine( aPos1, aPos2 );
+ }
+ nY += nEntryHeight;
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( nWinBits & WB_HASLINESATROOT )
+ {
+ pEntry = pView->First();
+ aPos1.X() = pView->GetTabPos( pEntry, pFirstDynamicTab);
+ // wenn keine ContextBitmap, dann etwas nach rechts
+ // unter den ersten Text (Node.Bmp ebenfalls
+ if( !pView->nContextBmpWidthMax )
+ aPos1.X() += aExpNodeBmp.GetSizePixel().Width() / 2;
+ aPos1.X() -= pView->GetIndent();
+ aPos1.Y() = GetEntryLine( pEntry );
+ aPos1.Y() += nEntryHeightDIV2;
+ pChild = pTree->LastSibling( pEntry );
+ aPos2.X() = aPos1.X();
+ aPos2.Y() = GetEntryLine( pChild );
+ aPos2.Y() += nEntryHeightDIV2;
+ pView->DrawLine( aPos1, aPos2 );
+ }
+ pView->SetLineColor( aOldLineColor );
+}
+
+
+static long GetOptSize( TabBar* pTabBar )
+{
+#if SUPD > 373
+ return pTabBar->CalcWindowSizePixel().Width();
+#else
+ long nWidth = 0;
+ USHORT nCount = pTabBar->GetPageCount();
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ USHORT nId = pTabBar->GetPageId( nCur );
+ nWidth+= pTabBar->GetTextSize(pTabBar->GetPageText(nId)).Width();
+ nWidth += 18;
+ }
+ return nWidth;
+#endif
+}
+
+void SvImpLBox::PositionScrollBars( Size& rSize, USHORT nMask )
+{
+ long nOverlap = 0;
+
+ Size aVerSize( nVerSBarWidth, rSize.Height() );
+ Size aHorSize( rSize.Width(), nHorSBarHeight );
+ long nTabBarWidth = 0;
+ if( pTabBar )
+ {
+ nTabBarWidth = GetOptSize( pTabBar );
+ long nMaxWidth = (rSize.Width() * 700) / 1000;
+ if( nTabBarWidth > nMaxWidth )
+ {
+ nTabBarWidth = nMaxWidth;
+ pTabBar->SetStyle( pTabBar->GetStyle() | WB_MINSCROLL );
+ }
+ else
+ {
+ WinBits nStyle = pTabBar->GetStyle();
+ nStyle &= ~(WB_MINSCROLL);
+ pTabBar->SetStyle( nStyle );
+ }
+ aHorSize.Width() -= nTabBarWidth;
+ Size aTabSize( pTabBar->GetSizePixel() );
+ aTabSize.Width() = nTabBarWidth;
+ pTabBar->SetSizePixel( aTabSize );
+ }
+ if( nMask & 0x0001 )
+ aHorSize.Width() -= nVerSBarWidth;
+ if( nMask & 0x0002 )
+ aVerSize.Height() -= nHorSBarHeight;
+
+ aVerSize.Height() += 2 * nOverlap;
+ Point aVerPos( rSize.Width() - aVerSize.Width() + nOverlap, -nOverlap );
+ aVerSBar.SetPosSizePixel( aVerPos, aVerSize );
+
+ aHorSize.Width() += 2 * nOverlap;
+ Point aHorPos( -nOverlap, rSize.Height() - aHorSize.Height() + nOverlap );
+ if( pTabBar )
+ pTabBar->SetPosPixel( aHorPos );
+ aHorPos.X() += nTabBarWidth;
+ aHorSBar.SetPosSizePixel( aHorPos, aHorSize );
+
+ if( nMask & 0x0001 )
+ rSize.Width() = aVerPos.X();
+ if( nMask & 0x0002 )
+ rSize.Height() = aHorPos.Y();
+ if( pTabBar )
+ pTabBar->Show();
+
+ if( (nMask & (0x0001|0x0002)) == (0x0001|0x0002) )
+ aScrBarBox.Show();
+ else
+ aScrBarBox.Hide();
+
+}
+
+// nResult: Bit0 == VerSBar Bit1 == HorSBar
+USHORT SvImpLBox::AdjustScrollBars( Size& rSize )
+{
+ long nEntryHeight = pView->GetEntryHeight();
+ if( !nEntryHeight )
+ return 0;
+
+ USHORT nResult = 0;
+
+ Size aOSize( pView->Control::GetOutputSizePixel() );
+
+ int bVerSBar = pView->nWindowStyle & WB_VSCROLL;
+ int bHorBar = 0;
+ long nMaxRight = aOSize.Width(); //GetOutputSize().Width();
+ Point aOrigin( pView->GetMapMode().GetOrigin() );
+ aOrigin.X() *= -1;
+ nMaxRight += aOrigin.X() - 1;
+ long nVis = nMostRight - aOrigin.X();
+ if( pTabBar || (
+ (pView->nWindowStyle & WB_HSCROLL) &&
+ (nVis < nMostRight || nMaxRight < nMostRight) ))
+ bHorBar = 1;
+
+ // Anzahl aller nicht eingeklappten Eintraege
+ ULONG nTotalCount = pView->GetVisibleCount();
+
+ // Anzahl in der View sichtbarer Eintraege
+ nVisibleCount = aOSize.Height() / nEntryHeight;
+
+ // muessen wir eine vertikale Scrollbar einblenden?
+ if( bVerSBar || nTotalCount > nVisibleCount - 1 )
+ {
+ nResult = 1;
+ nFlags |= F_HOR_SBARSIZE_WITH_VBAR;
+ nMaxRight -= nVerSBarWidth;
+ if( !bHorBar )
+ {
+ if( (pView->nWindowStyle & WB_HSCROLL) &&
+ (nVis < nMostRight || nMaxRight < nMostRight) )
+ bHorBar = 1;
+ }
+ }
+
+ // muessen wir eine horizontale Scrollbar einblenden?
+ if( bHorBar )
+ {
+ nResult |= 0x0002;
+ // die Anzahl der in der View sichtbaren Eintraege
+ // muss neu berechnet werden, da die horizontale
+ // ScrollBar eingeblendet wird
+ nVisibleCount = (aOSize.Height() - nHorSBarHeight) / nEntryHeight;
+ // eventuell brauchen wir jetzt doch eine vertikale ScrollBar
+ if( !(nResult & 0x0001) &&
+ ((nTotalCount > nVisibleCount - 1) || bVerSBar) )
+ {
+ nResult = 3;
+ nFlags |= F_VER_SBARSIZE_WITH_HBAR;
+ }
+ }
+
+ PositionScrollBars( aOSize, nResult );
+
+ // Range, VisibleRange usw. anpassen
+
+ // Output-Size aktualisieren, falls wir scrollen muessen
+ Rectangle aRect;
+ aRect.SetSize( aOSize );
+ aSelEng.SetVisibleArea( aRect );
+
+ // Vertikale ScrollBar
+ long nTemp = (long)nVisibleCount;
+ nTemp--;
+ if( nTemp != aVerSBar.GetVisibleSize() )
+ {
+ if( !bInVScrollHdl )
+ {
+ aVerSBar.SetPageSize( nTemp - 1 );
+ aVerSBar.SetVisibleSize( nTemp );
+ }
+ else
+ {
+ nFlags |= F_ENDSCROLL_SET_VIS_SIZE;
+ nNextVerVisSize = nTemp;
+ }
+ }
+
+ // Horizontale ScrollBar
+ nTemp = aHorSBar.GetThumbPos();
+ aHorSBar.SetVisibleSize( aOSize.Width() );
+ long nNewThumbPos = aHorSBar.GetThumbPos();
+ Range aRange( aHorSBar.GetRange() );
+ if( aRange.Max() < nMostRight+25 )
+ {
+ aRange.Max() = nMostRight+25;
+ aHorSBar.SetRange( aRange );
+ }
+
+ if( nTemp != nNewThumbPos )
+ {
+ nTemp = nNewThumbPos - nTemp;
+ if( pView->IsEditingActive() )
+ {
+ pView->EndEditing( TRUE ); // Cancel
+ pView->Update();
+ }
+ pView->nFocusWidth = -1;
+ KeyLeftRight( nTemp );
+ }
+
+ if( nResult & 0x0001 )
+ aVerSBar.Show();
+ else
+ aVerSBar.Hide();
+
+ if( nResult & 0x0002 )
+ aHorSBar.Show();
+ else
+ {
+ if( !pTabBar )
+ aHorSBar.Hide();
+ }
+ rSize = aOSize;
+ return nResult;
+}
+
+void SvImpLBox::InitScrollBarBox()
+{
+ aScrBarBox.SetSizePixel( Size(nVerSBarWidth, nHorSBarHeight) );
+ Size aSize( pView->Control::GetOutputSizePixel() );
+ aScrBarBox.SetPosPixel( Point(aSize.Width()-nVerSBarWidth, aSize.Height()-nHorSBarHeight));
+}
+
+void SvImpLBox::Resize()
+{
+ Size aSize( pView->Control::GetOutputSizePixel());
+ if( aSize.Width() <= 0 || aSize.Height() <= 0 )
+ return;
+ nFlags |= F_IN_RESIZE;
+ InitScrollBarBox();
+
+ if( pView->GetEntryHeight())
+ {
+ AdjustScrollBars( aOutputSize );
+ FillView();
+ }
+ // !!!HACK, da in Floating- & Docking-Windows nach Resizes
+ // die Scrollbars nicht richtig, bzw. ueberhaupt nicht gezeichnet werden
+ if( aHorSBar.IsVisible())
+ aHorSBar.Invalidate();
+ if( aVerSBar.IsVisible())
+ aVerSBar.Invalidate();
+ nFlags &= (~(F_IN_RESIZE | F_PAINTED));
+}
+
+void SvImpLBox::FillView()
+{
+ if( !pStartEntry )
+ {
+ USHORT nVisibleCount = (USHORT)(pView->GetVisibleCount());
+ USHORT nTempThumb = (USHORT)aVerSBar.GetThumbPos();
+ if( nTempThumb >= nVisibleCount )
+ nTempThumb = nVisibleCount - 1;
+ pStartEntry = (SvLBoxEntry*)(pView->GetEntryAtVisPos(nTempThumb));
+ }
+ if( pStartEntry )
+ {
+ USHORT nLast = (USHORT)(pView->GetVisiblePos( (SvLBoxEntry*)(pView->LastVisible())));
+ USHORT nThumb = (USHORT)(pView->GetVisiblePos( pStartEntry ));
+ USHORT nCurDispEntries = nLast-nThumb+1;
+ if( nCurDispEntries < nVisibleCount )
+ {
+ ShowCursor( FALSE );
+ // Fenster fuellen, indem der Thumb schrittweise
+ // nach oben bewegt wird
+ BOOL bFound = FALSE;
+ SvLBoxEntry* pTemp = pStartEntry;
+ while( nCurDispEntries < nVisibleCount && pTemp )
+ {
+ pTemp = (SvLBoxEntry*)(pView->PrevVisible(pStartEntry));
+ if( pTemp )
+ {
+ nThumb--;
+ pStartEntry = pTemp;
+ nCurDispEntries++;
+ bFound = TRUE;
+ }
+ }
+ if( bFound )
+ {
+ aVerSBar.SetThumbPos( nThumb );
+ ShowCursor( TRUE ); // Focusrect neu berechnen
+ pView->Invalidate();
+ }
+ }
+ }
+}
+
+
+
+
+void SvImpLBox::ShowVerSBar()
+{
+ USHORT bVerBar = pView->nWindowStyle & WB_VSCROLL;
+ ULONG nVis;
+ if( !bVerBar )
+ nVis = pView->GetVisibleCount();
+ if( bVerBar || (nVisibleCount && nVis > (ULONG)(nVisibleCount-1)) )
+ {
+ if( !aVerSBar.IsVisible() )
+ {
+ pView->nFocusWidth = -1;
+ AdjustScrollBars( aOutputSize );
+ if( GetUpdateMode() )
+ aVerSBar.Update();
+ }
+ }
+ else
+ {
+ if( aVerSBar.IsVisible() )
+ {
+ pView->nFocusWidth = -1;
+ AdjustScrollBars( aOutputSize );
+ }
+ }
+
+ long nMaxRight = GetOutputSize().Width();
+ Point aPos( pView->GetMapMode().GetOrigin() );
+ aPos.X() *= -1; // Umrechnung Dokumentkoord.
+ nMaxRight = nMaxRight + aPos.X() - 1;
+ if( nMaxRight < nMostRight )
+ {
+ if( !aHorSBar.IsVisible() )
+ {
+ pView->nFocusWidth = -1;
+ AdjustScrollBars( aOutputSize );
+ if( GetUpdateMode() )
+ aHorSBar.Update();
+ }
+ else
+ {
+ Range aRange( aHorSBar.GetRange() );
+ if( aRange.Max() < nMostRight+25 )
+ {
+ aRange.Max() = nMostRight+25;
+ aHorSBar.SetRange( aRange );
+ }
+ else
+ {
+ pView->nFocusWidth = -1;
+ AdjustScrollBars( aOutputSize );
+ }
+ }
+ }
+ else
+ {
+ if( aHorSBar.IsVisible() )
+ {
+ pView->nFocusWidth = -1;
+ AdjustScrollBars( aOutputSize );
+ }
+ }
+}
+
+
+void SvImpLBox::SyncVerThumb()
+{
+ if( pStartEntry )
+ {
+ long nEntryPos = pView->GetVisiblePos( pStartEntry );
+ aVerSBar.SetThumbPos( nEntryPos );
+ }
+ else
+ aVerSBar.SetThumbPos( 0 );
+}
+
+BOOL SvImpLBox::IsEntryInView( SvLBoxEntry* pEntry ) const
+{
+ // Parent eingeklappt
+ if( !pView->IsEntryVisible(pEntry) )
+ return FALSE;
+ long nY = GetEntryLine( pEntry );
+ if( nY < 0 )
+ return FALSE;
+ long nMax = nVisibleCount * pView->GetEntryHeight();
+ if( nY >= nMax )
+ return FALSE;
+ return TRUE;
+}
+
+
+long SvImpLBox::GetEntryLine( SvLBoxEntry* pEntry ) const
+{
+ if(!pStartEntry )
+ return -1; // unsichtbare Position
+
+ long nFirstVisPos = pView->GetVisiblePos( pStartEntry );
+ long nEntryVisPos = pView->GetVisiblePos( pEntry );
+ nFirstVisPos = nEntryVisPos - nFirstVisPos;
+ nFirstVisPos *= pView->GetEntryHeight();
+ return nFirstVisPos;
+}
+
+void SvImpLBox::SetEntryHeight( short /* nHeight */ )
+{
+ SetNodeBmpYOffset( aExpNodeBmp );
+ SetNodeBmpYOffset( aCollNodeBmp );
+ if(!pView->HasViewData()) // stehen wir im Clear?
+ {
+ Size aSize = pView->Control::GetOutputSizePixel();
+ AdjustScrollBars( aSize );
+ }
+ else
+ {
+ Resize();
+ if( GetUpdateMode() )
+ pView->Invalidate();
+ }
+}
+
+
+
+// ***********************************************************************
+// Callback-Functions
+// ***********************************************************************
+
+void SvImpLBox::IndentChanged( short /* nIndentPixel */ ) {}
+
+void SvImpLBox::EntryExpanded( SvLBoxEntry* pEntry )
+{
+ // SelAllDestrAnch( FALSE, TRUE ); //DeselectAll();
+ if( GetUpdateMode() )
+ {
+ ShowCursor( FALSE );
+ long nY = GetEntryLine( pEntry );
+ if( IsLineVisible(nY) )
+ {
+ InvalidateEntriesFrom( nY );
+ FindMostRight( pEntry, 0 );
+ }
+ aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
+ // falls vor dem Thumb expandiert wurde, muss
+ // die Thumb-Position korrigiert werden.
+ SyncVerThumb();
+ ShowVerSBar();
+ ShowCursor( TRUE );
+ }
+}
+
+void SvImpLBox::EntryCollapsed( SvLBoxEntry* pEntry )
+{
+ if( !pView->IsEntryVisible( pEntry ) )
+ return;
+
+ ShowCursor( FALSE );
+
+ if( !pMostRightEntry || pTree->IsChild( pEntry,pMostRightEntry ) )
+ {
+ FindMostRight(0);
+ }
+
+ if( pStartEntry )
+ {
+ long nOldThumbPos = aVerSBar.GetThumbPos();
+ ULONG nVisList = pView->GetVisibleCount();
+ aVerSBar.SetRange( Range(0, nVisList-1) );
+ long nNewThumbPos = aVerSBar.GetThumbPos();
+ if( nNewThumbPos != nOldThumbPos )
+ {
+ pStartEntry = pView->First();
+ USHORT nDistance = (USHORT)nNewThumbPos;
+ if( nDistance )
+ pStartEntry = (SvLBoxEntry*)(pView->NextVisible( pStartEntry,
+ nDistance));
+ if( GetUpdateMode() )
+ pView->Invalidate();
+ }
+ else
+ SyncVerThumb();
+ ShowVerSBar();
+ }
+ // wurde Cursor eingeklappt ?
+ if( pTree->IsChild( pEntry, pCursor ) )
+ SetCursor( pEntry );
+ if( GetUpdateMode() )
+ ShowVerSBar();
+ ShowCursor( TRUE );
+ if( GetUpdateMode() )
+ pView->Select( pCursor, TRUE );
+}
+
+void SvImpLBox::CollapsingEntry( SvLBoxEntry* pEntry )
+{
+ if( !pView->IsEntryVisible( pEntry ) || !pStartEntry )
+ return;
+
+ SelAllDestrAnch( FALSE, TRUE ); // deselectall
+
+ // ist der eingeklappte Parent sichtbar ?
+ long nY = GetEntryLine( pEntry );
+ if( IsLineVisible(nY) )
+ {
+ if( GetUpdateMode() )
+ InvalidateEntriesFrom( nY );
+ }
+ else
+ {
+ if( pTree->IsChild(pEntry, pStartEntry) )
+ {
+ pStartEntry = pEntry;
+ if( GetUpdateMode() )
+ pView->Invalidate();
+ }
+ }
+}
+
+
+void SvImpLBox::SetNodeBmpYOffset( const Image& rBmp )
+{
+ Size aSize;
+ nYoffsNodeBmp = pView->GetHeightOffset( rBmp, aSize );
+ nNodeBmpWidth = aSize.Width();
+}
+
+void SvImpLBox::SetNodeBmpTabDistance()
+{
+ nNodeBmpTabDistance = -pView->GetIndent();
+ if( pView->nContextBmpWidthMax )
+ {
+ // nur, wenn der erste dynamische Tab zentriert ist
+ // (setze ich momentan voraus)
+ Size aSize = aExpNodeBmp.GetSizePixel();
+ nNodeBmpTabDistance -= aSize.Width() / 2;
+ }
+}
+
+//
+// korrigiert bei SingleSelection den Cursor
+//
+void SvImpLBox::EntrySelected( SvLBoxEntry* pEntry, BOOL bSelect )
+{
+ if( nFlags & F_IGNORE_SELECT )
+ return;
+
+ /*
+ if( (nWinBits & WB_HIDESELECTION) && pEntry && !pView->HasFocus() )
+ {
+ SvViewData* pViewData = pView->GetViewData( pEntry );
+ pViewData->SetCursored( bSelect );
+ }
+ */
+
+ nFlags &= (~F_DESEL_ALL);
+ if( bSelect &&
+ aSelEng.GetSelectionMode() == SINGLE_SELECTION &&
+ pEntry != pCursor )
+ {
+ SetCursor( pEntry );
+ DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?")
+ }
+
+ if( GetUpdateMode() && pView->IsEntryVisible(pEntry) )
+ {
+ long nY = GetEntryLine( pEntry );
+ if( IsLineVisible( nY ) )
+ {
+ ShowCursor( FALSE );
+ pView->PaintEntry1( pEntry, nY, 0xffff ); // wg. ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
+ ShowCursor( TRUE );
+ }
+ }
+}
+
+
+void SvImpLBox::RemovingEntry( SvLBoxEntry* pEntry )
+{
+ DestroyAnchor();
+
+ if( !pView->IsEntryVisible( pEntry ) )
+ {
+ // wenn Parent eingeklappt, dann tschuess
+ nFlags |= F_REMOVED_ENTRY_INVISIBLE;
+ return;
+ }
+
+ if( pEntry == pMostRightEntry || (
+ pEntry->HasChilds() && pView->IsExpanded(pEntry) &&
+ pTree->IsChild(pEntry, pMostRightEntry)))
+ {
+ nFlags |= F_REMOVED_RECALC_MOST_RIGHT;
+ }
+
+ SvLBoxEntry* pOldStartEntry = pStartEntry;
+
+ SvLBoxEntry* pParent = (SvLBoxEntry*)(pView->GetModel()->GetParent(pEntry));
+
+ if( pParent && pView->GetModel()->GetChildList(pParent)->Count() == 1 )
+ {
+ DBG_ASSERT( pView->IsExpanded( pParent ), "Parent not expanded");
+ pParent->SetFlags( pParent->GetFlags() | SV_ENTRYFLAG_NO_NODEBMP);
+ InvalidateEntry( pParent );
+ }
+
+ if( pCursor && pTree->IsChild( pEntry, pCursor) )
+ pCursor = pEntry;
+ if( pStartEntry && pTree->IsChild(pEntry,pStartEntry) )
+ pStartEntry = pEntry;
+
+ SvLBoxEntry* pTemp;
+ if( pCursor && pCursor == pEntry )
+ {
+ if( bSimpleTravel )
+ pView->Select( pCursor, FALSE );
+ ShowCursor( FALSE ); // Focus-Rect weg
+ // NextSibling, weil auch Childs des Cursors geloescht werden
+ pTemp = pView->NextSibling( pCursor );
+ if( !pTemp )
+ pTemp = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
+
+ SetCursor( pTemp, TRUE );
+ }
+ if( pStartEntry && pStartEntry == pEntry )
+ {
+ pTemp = pView->NextSibling( pStartEntry );
+ if( !pTemp )
+ pTemp = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry ));
+ pStartEntry = pTemp;
+ }
+ if( GetUpdateMode())
+ {
+ // wenns der letzte ist, muss invalidiert werden, damit die Linien
+ // richtig gezeichnet (in diesem Fall geloescht) werden.
+ if( pStartEntry && (pStartEntry != pOldStartEntry || pEntry == (SvLBoxEntry*)pView->GetModel()->Last()) )
+ {
+ aVerSBar.SetThumbPos( pView->GetVisiblePos( pStartEntry ));
+ pView->Invalidate( GetVisibleArea() );
+ }
+ else
+ InvalidateEntriesFrom( GetEntryLine( pEntry ) );
+ }
+}
+
+void SvImpLBox::EntryRemoved()
+{
+ if( nFlags & F_REMOVED_ENTRY_INVISIBLE )
+ {
+ nFlags &= (~F_REMOVED_ENTRY_INVISIBLE);
+ return;
+ }
+ if( !pStartEntry )
+ pStartEntry = pTree->First();
+ if( !pCursor )
+ SetCursor( pStartEntry, TRUE );
+
+ if( pCursor && (bSimpleTravel || !pView->GetSelectionCount() ))
+ pView->Select( pCursor, TRUE );
+
+ if( GetUpdateMode())
+ {
+ if( nFlags & F_REMOVED_RECALC_MOST_RIGHT )
+ FindMostRight(0);
+ aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1 ) );
+ FillView();
+ if( pStartEntry )
+ // falls ueber dem Thumb geloescht wurde
+ aVerSBar.SetThumbPos( pView->GetVisiblePos( pStartEntry) );
+
+ ShowVerSBar();
+ if( pCursor && pView->HasFocus() && !pView->IsSelected(pCursor) )
+ {
+ if( pView->GetSelectionCount() )
+ {
+ // ist ein benachbarter Eintrag selektiert?
+ SvLBoxEntry* pNextCursor = (SvLBoxEntry*)pView->PrevVisible( pCursor );
+ if( !pNextCursor || !pView->IsSelected( pNextCursor ))
+ pNextCursor = (SvLBoxEntry*)pView->NextVisible( pCursor );
+ if( !pNextCursor || !pView->IsSelected( pNextCursor ))
+ // kein Nachbar selektiert: Ersten selektierten nehmen
+ pNextCursor = pView->FirstSelected();
+ SetCursor( pNextCursor );
+ MakeVisible( pCursor );
+ }
+ else
+ pView->Select( pCursor, TRUE );
+ }
+ ShowCursor( TRUE );
+ }
+ nFlags &= (~F_REMOVED_RECALC_MOST_RIGHT);
+}
+
+
+void SvImpLBox::MovingEntry( SvLBoxEntry* pEntry )
+{
+ int bDeselAll = nFlags & F_DESEL_ALL;
+ SelAllDestrAnch( FALSE, TRUE ); // DeselectAll();
+ if( !bDeselAll )
+ nFlags &= (~F_DESEL_ALL);
+
+ if( pEntry == pCursor )
+ ShowCursor( FALSE );
+ if( IsEntryInView( pEntry ) )
+ pView->Invalidate();
+ if( pEntry == pStartEntry )
+ {
+ SvLBoxEntry* pNew = 0;
+ if( !pEntry->HasChilds() )
+ {
+ pNew = (SvLBoxEntry*)(pView->NextVisible( pStartEntry ));
+ if( !pNew )
+ pNew = (SvLBoxEntry*)(pView->PrevVisible( pStartEntry ));
+ }
+ else
+ {
+ pNew = pTree->NextSibling( pEntry );
+ if( !pNew )
+ pNew = pTree->PrevSibling( pEntry );
+ }
+ pStartEntry = pNew;
+ }
+}
+
+void SvImpLBox::EntryMoved( SvLBoxEntry* pEntry )
+{
+ aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1));
+ USHORT nFirstPos = (USHORT)pTree->GetAbsPos( pStartEntry );
+ USHORT nNewPos = (USHORT)pTree->GetAbsPos( pEntry );
+ FindMostRight(0);
+ if( nNewPos < nFirstPos )
+ {
+ //!!!Notloesung
+ pStartEntry = pEntry;
+ SyncVerThumb();
+ }
+ if( pEntry == pCursor )
+ {
+ if( pView->IsEntryVisible( pCursor ) )
+ ShowCursor( TRUE );
+ else
+ {
+ SvLBoxEntry* pParent = pEntry;
+ do {
+ pParent = pTree->GetParent( pParent );
+ }
+ while( !pView->IsEntryVisible( pParent ) );
+ SetCursor( pParent );
+ }
+ }
+ if( IsEntryInView( pEntry ) )
+ pView->Invalidate();
+}
+
+
+
+void SvImpLBox::EntryInserted( SvLBoxEntry* pEntry )
+{
+ if( GetUpdateMode() )
+ {
+ SvLBoxEntry* pParent = (SvLBoxEntry*)pTree->GetParent(pEntry);
+ if( pParent && pTree->GetChildList(pParent)->Count() == 1 )
+ // Pluszeichen zeichnen
+ pTree->InvalidateEntry( pParent );
+
+ if( !pView->IsEntryVisible( pEntry ) )
+ return;
+ int bDeselAll = nFlags & F_DESEL_ALL;
+ if( bDeselAll )
+ SelAllDestrAnch( FALSE, TRUE );
+ else
+ DestroyAnchor();
+ // nFlags &= (~F_DESEL_ALL);
+// ShowCursor( FALSE ); // falls sich Cursor nach unten verschiebt
+ long nY = GetEntryLine( pEntry );
+ BOOL bEntryVisible = IsLineVisible( nY );
+ BOOL bPrevEntryVisible = IsLineVisible(nY-pView->GetEntryHeight());
+ if( bEntryVisible )
+ {
+ ShowCursor( FALSE ); // falls sich Cursor nach unten verschiebt
+ nY -= pView->GetEntryHeight(); // wg. Linien
+ InvalidateEntriesFrom( nY );
+ }
+ else if( pStartEntry && nY < GetEntryLine(pStartEntry) )
+ {
+ // pruefen, ob die View komplett gefuellt ist. Wenn
+ // nicht, dann pStartEntry und den Cursor anpassen
+ // (automatisches scrollen)
+ USHORT nLast = (USHORT)(pView->GetVisiblePos( (SvLBoxEntry*)(pView->LastVisible())));
+ USHORT nThumb = (USHORT)(pView->GetVisiblePos( pStartEntry ));
+ USHORT nCurDispEntries = nLast-nThumb+1;
+ if( nCurDispEntries < nVisibleCount )
+ {
+ // beim naechsten Paint-Event setzen
+ pStartEntry = 0;
+ SetCursor( 0 );
+ pView->Invalidate();
+ }
+ }
+ else if( !pStartEntry )
+ pView->Invalidate();
+
+ // die Linien invalidieren
+ /*
+ if( (bEntryVisible || bPrevEntryVisible) &&
+ (nWinBits & ( WB_HASLINES | WB_HASLINESATROOT )) )
+ {
+ SvLBoxTab* pTab = pView->GetFirstDynamicTab();
+ if( pTab )
+ {
+ long nDX = pView->GetTabPos( pEntry, pTab );
+ Point aTmpPoint;
+ Size aSize( nDX, nY );
+ Rectangle aRect( aTmpPoint, aSize );
+ pView->Invalidate( aRect );
+ }
+ }
+ */
+
+ SetMostRight( pEntry );
+ aVerSBar.SetRange( Range(0, pView->GetVisibleCount()-1));
+ SyncVerThumb(); // falls vor Thumb eingefuegt wurde
+ ShowVerSBar();
+ ShowCursor( TRUE );
+//#if SUPD > 364
+ if( pStartEntry != pView->First() && (nFlags & F_FILLING) )
+ pView->Update();
+//#endif
+ }
+}
+
+
+
+// ********************************************************************
+// Eventhandler
+// ********************************************************************
+
+
+// ****** Steuerung der Controlanimation
+
+BOOL SvImpLBox::ButtonDownCheckCtrl(const MouseEvent& rMEvt, SvLBoxEntry* pEntry,
+ long nY )
+{
+ SvLBoxItem* pItem = pView->GetItem(pEntry,rMEvt.GetPosPixel().X(),&pActiveTab);
+ if( pItem && (pItem->IsA()==SV_ITEM_ID_LBOXBUTTON))
+ {
+ pActiveButton = (SvLBoxButton*)pItem;
+ pActiveEntry = pEntry;
+ if( pCursor == pActiveEntry )
+ pView->HideFocus();
+ pView->CaptureMouse();
+ pActiveButton->SetStateHilighted( TRUE );
+ pView->PaintEntry1( pActiveEntry, nY,
+ SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
+ SV_LBOXTAB_ADJUST_RIGHT );
+ return TRUE;
+ }
+ else
+ pActiveButton = 0;
+ return FALSE;
+}
+
+BOOL SvImpLBox::MouseMoveCheckCtrl( const MouseEvent& rMEvt, SvLBoxEntry* pEntry)
+{
+ if( pActiveButton )
+ {
+ long nY;
+ long nMouseX = rMEvt.GetPosPixel().X();
+ if( pEntry == pActiveEntry &&
+ pView->GetItem(pActiveEntry, nMouseX) == pActiveButton )
+ {
+ if( !pActiveButton->IsStateHilighted() )
+ {
+ pActiveButton->SetStateHilighted(TRUE );
+ nY = GetEntryLine( pActiveEntry );
+ pView->PaintEntry1( pActiveEntry, nY,
+ SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
+ SV_LBOXTAB_ADJUST_RIGHT );
+ }
+ }
+ else
+ {
+ if( pActiveButton->IsStateHilighted() )
+ {
+ pActiveButton->SetStateHilighted(FALSE );
+ nY = GetEntryLine( pActiveEntry );
+ pView->PaintEntry1( pActiveEntry, nY, SV_LBOXTAB_PUSHABLE );
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL SvImpLBox::ButtonUpCheckCtrl( const MouseEvent& rMEvt )
+{
+ if( pActiveButton )
+ {
+ pView->ReleaseMouse();
+ SvLBoxEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
+ long nY = GetEntryLine( pActiveEntry );
+ pActiveButton->SetStateHilighted( FALSE );
+ long nMouseX = rMEvt.GetPosPixel().X();
+ if( pEntry == pActiveEntry &&
+ pView->GetItem( pActiveEntry, nMouseX ) == pActiveButton )
+ pActiveButton->ClickHdl( pView, pActiveEntry );
+ pView->PaintEntry1( pActiveEntry, nY,
+ SV_LBOXTAB_PUSHABLE | SV_LBOXTAB_ADJUST_CENTER |
+ SV_LBOXTAB_ADJUST_RIGHT );
+ if( pCursor == pActiveEntry )
+ ShowCursor( TRUE );
+ pActiveButton = 0;
+ pActiveEntry = 0;
+ pActiveTab = 0;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+// ******* Steuerung Plus/Minus-Button zum Expandieren/Kollabieren
+
+// FALSE == kein Expand/Collapse-Button getroffen
+BOOL SvImpLBox::IsNodeButton( const Point& rPosPixel, SvLBoxEntry* pEntry ) const
+{
+ if( !pEntry->HasChilds() && !pEntry->HasChildsOnDemand() )
+ return FALSE;
+
+ SvLBoxTab* pFirstDynamicTab = pView->GetFirstDynamicTab();
+ if( !pFirstDynamicTab )
+ return FALSE;
+
+ long nMouseX = rPosPixel.X();
+ // in Doc-Koords umrechnen
+ Point aOrigin( pView->GetMapMode().GetOrigin() );
+ nMouseX -= aOrigin.X();
+
+ long nX = pView->GetTabPos( pEntry, pFirstDynamicTab);
+ nX += nNodeBmpTabDistance;
+ if( nMouseX < nX )
+ return FALSE;
+ nX += nNodeBmpWidth;
+ if( nMouseX > nX )
+ return FALSE;
+ return TRUE;
+}
+
+// FALSE == kein Expand/Collapse-Button getroffen
+BOOL SvImpLBox::ButtonDownCheckExpand( const MouseEvent& rMEvt,
+ SvLBoxEntry* pEntry, long /* nY */ )
+{
+ // beim Inplace-Ed. gunnix machen
+ if( pView->IsEditingActive() && pEntry == pView->pEdEntry )
+ return TRUE;
+
+ if( IsNodeButton( rMEvt.GetPosPixel(), pEntry ) )
+ {
+ if( rMEvt.GetClicks() == 1 )
+ {
+ if( pView->IsExpanded(pEntry) )
+ {
+ pView->EndEditing( TRUE );
+ pView->Collapse( pEntry );
+ }
+ else
+ {
+ //einen Entry, der editiert wird, darf man aufklappen
+ pView->Expand( pEntry );
+ }
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void SvImpLBox::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ if ( !rMEvt.IsLeft() && !rMEvt.IsRight())
+ return;
+
+#ifdef OS2
+ // unter OS/2 kommt zwischen MouseButtonDown und
+ // MouseButtonUp ein MouseMove
+ nFlags |= F_IGNORE_NEXT_MOUSEMOVE;
+#endif
+ aEditTimer.Stop();
+ Point aPos( rMEvt.GetPosPixel());
+
+ if( aPos.X() > aOutputSize.Width() || aPos.Y() > aOutputSize.Height() )
+ return;
+
+ nFlags &= (~F_FILLING);
+ pView->GrabFocus();
+ SvLBoxEntry* pEntry = GetEntry( aPos );
+ if( !pEntry )
+ return;
+
+ long nY = GetEntryLine( pEntry );
+ // Node-Button?
+ if( ButtonDownCheckExpand( rMEvt, pEntry, nY ) )
+ return;
+
+ if( !EntryReallyHit(pEntry,aPos,nY))
+ return;
+
+//#if defined(MAC) || defined(OV_DEBUG)
+ SvLBoxItem* pXItem = pView->GetItem( pEntry, aPos.X() );
+ if( pXItem )
+ {
+ SvLBoxTab* pXTab = pView->GetTab( pEntry, pXItem );
+ if( !rMEvt.IsMod1() && !rMEvt.IsMod2() &&pXTab->IsEditable() )
+ nFlags |= F_START_EDITTIMER;
+#ifndef MAC
+ if( !pView->IsSelected( pEntry ))
+ nFlags &= ~F_START_EDITTIMER;
+#endif
+ }
+//#endif
+
+
+ if( (rMEvt.GetClicks() % 2) == 0 )
+ {
+//#ifdef MAC
+ nFlags &= (~F_START_EDITTIMER);
+//#endif
+ pView->pHdlEntry = pEntry;
+ if( pView->DoubleClickHdl() )
+ {
+ // falls im Handler der Eintrag geloescht wurde
+ pEntry = GetClickedEntry( aPos );
+ if( !pEntry )
+ return;
+ if( pEntry != pView->pHdlEntry )
+ {
+ // neu selektieren & tschuess
+ if( !bSimpleTravel && !aSelEng.IsAlwaysAdding())
+ SelAllDestrAnch( FALSE, TRUE ); // DeselectAll();
+ SetCursor( pEntry );
+ return;
+ }
+ if( pEntry->HasChilds() || pEntry->HasChildsOnDemand() )
+ {
+ if( pView->IsExpanded(pEntry) )
+ pView->Collapse( pEntry );
+ else
+ pView->Expand( pEntry );
+ if( pEntry == pCursor ) // nur wenn Entryitem angeklickt wurde
+ // (Nodebutton ist kein Entryitem!)
+ pView->Select( pCursor, TRUE );
+ return;
+ }
+ }
+ }
+ else
+ {
+ // CheckButton? (TreeListBox: Check + Info)
+ if( ButtonDownCheckCtrl(rMEvt, pEntry, nY) == TRUE)
+ return;
+ // Inplace-Editing?
+//#ifndef MAC
+#if 0
+ if( rMEvt.IsMod2() && pView->IsInplaceEditingEnabled() )
+ {
+ SvLBoxItem* pItem = pView->GetItem( pEntry, aPos.X() );
+ if( pItem )
+ pView->EditingRequest( pEntry, pItem, aPos );
+ return;
+ }
+#endif
+ }
+ aSelEng.SelMouseButtonDown( rMEvt );
+}
+
+void SvImpLBox::MouseButtonUp( const MouseEvent& rMEvt)
+{
+#ifdef OS2
+ nFlags &= (~F_IGNORE_NEXT_MOUSEMOVE);
+#endif
+ if(!ButtonUpCheckCtrl( rMEvt ) )
+ aSelEng.SelMouseButtonUp( rMEvt );
+ EndScroll();
+//#if defined(MAC) || defined(OV_DEBUG)
+ if( nFlags & F_START_EDITTIMER )
+ {
+ nFlags &= (~F_START_EDITTIMER);
+ aEditTimer.Start();
+ }
+//#endif
+
+ return;
+}
+
+void SvImpLBox::MouseMove( const MouseEvent& rMEvt)
+{
+#ifdef OS2
+ if( nFlags & F_IGNORE_NEXT_MOUSEMOVE )
+ {
+ nFlags &= (~F_IGNORE_NEXT_MOUSEMOVE);
+ return;
+ }
+#endif
+ SvLBoxEntry* pEntry = GetClickedEntry( rMEvt.GetPosPixel() );
+ if(!MouseMoveCheckCtrl( rMEvt, pEntry ) )
+ aSelEng.SelMouseMove( rMEvt );
+ return;
+}
+
+BOOL SvImpLBox::KeyInput( const KeyEvent& rKEvt)
+{
+//#if defined(MAC) || defined(OV_DEBUG)
+ aEditTimer.Stop();
+//#endif
+
+ if( rKEvt.GetKeyCode().IsMod2() )
+ return FALSE; // Alt-Taste nicht auswerten
+
+ nFlags &= (~F_FILLING);
+
+ if( !pCursor )
+ pCursor = pStartEntry;
+ if( !pCursor )
+ return FALSE;
+
+ BOOL bKeyUsed = TRUE;
+
+ USHORT nDelta = (USHORT)aVerSBar.GetPageSize();
+ USHORT aCode = rKEvt.GetKeyCode().GetCode();
+
+ BOOL bShift = rKEvt.GetKeyCode().IsShift();
+ BOOL bMod1 = rKEvt.GetKeyCode().IsMod1();
+
+ SvLBoxEntry* pNewCursor;
+ long nThumb;
+
+ switch( aCode )
+ {
+ case KEY_UP:
+ if( !IsEntryInView( pCursor ) )
+ MakeVisible( pCursor );
+ pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pCursor ));
+ if( pNewCursor )
+ {
+ aSelEng.CursorPosChanging( bShift, bMod1 );
+ if( IsEntryInView( pNewCursor ) )
+ SetCursor( pNewCursor );
+ else
+ {
+ SetCursor( pNewCursor );
+ KeyUp( FALSE );
+ }
+ }
+ break;
+
+ case KEY_DOWN:
+ if( !IsEntryInView( pCursor ) )
+ MakeVisible( pCursor );
+ pNewCursor = (SvLBoxEntry*)(pView->NextVisible( pCursor ));
+ if( pNewCursor )
+ {
+ aSelEng.CursorPosChanging( bShift, bMod1 );
+ if( IsEntryInView( pNewCursor ) )
+ SetCursor( pNewCursor );
+ else
+ {
+ if( pCursor )
+ pView->Select( pCursor, FALSE );
+ KeyDown( FALSE );
+ SetCursor( pNewCursor );
+ }
+ }
+ else
+ KeyDown( FALSE ); // weil ScrollBar-Range evtl. noch
+ // scrollen erlaubt
+ break;
+
+ case KEY_RIGHT:
+ if( pView->nWindowStyle & WB_HSCROLL )
+ {
+ nThumb = aHorSBar.GetThumbPos();
+ nThumb += aHorSBar.GetLineSize();
+ long nOldThumb = aHorSBar.GetThumbPos();
+ aHorSBar.SetThumbPos( nThumb );
+ nThumb = nOldThumb;
+ nThumb -= aHorSBar.GetThumbPos();
+ nThumb *= -1;
+ if( nThumb )
+ {
+ KeyLeftRight( nThumb );
+ EndScroll();
+ }
+ }
+ else
+ bKeyUsed = FALSE;
+ break;
+
+ case KEY_LEFT:
+ if( pView->nWindowStyle & WB_HSCROLL )
+ {
+ nThumb = aHorSBar.GetThumbPos();
+ nThumb -= aHorSBar.GetLineSize();
+ long nOldThumb = aHorSBar.GetThumbPos();
+ aHorSBar.SetThumbPos( nThumb );
+ nThumb = nOldThumb;
+ nThumb -= aHorSBar.GetThumbPos();
+ if( nThumb )
+ {
+ KeyLeftRight( -nThumb );
+ EndScroll();
+ }
+ }
+ else
+ bKeyUsed = FALSE;
+ break;
+
+ case KEY_PAGEUP:
+ if( !bMod1 )
+ {
+ pNewCursor = (SvLBoxEntry*)(pView->PrevVisible( pCursor, nDelta ));
+ if( nDelta )
+ {
+ DBG_ASSERT(pNewCursor&&(ULONG)pNewCursor!=(ULONG)pCursor,"Cursor?")
+ aSelEng.CursorPosChanging( bShift, bMod1 );
+ if( IsEntryInView( pNewCursor ) )
+ SetCursor( pNewCursor );
+ else
+ {
+ SetCursor( pNewCursor );
+ KeyUp( TRUE );
+ }
+ }
+ }
+ else
+ bKeyUsed = FALSE;
+ break;
+
+ case KEY_PAGEDOWN:
+ if( !bMod1 )
+ {
+ pNewCursor= (SvLBoxEntry*)(pView->NextVisible( pCursor, nDelta ));
+ if( nDelta )
+ {
+ DBG_ASSERT(pNewCursor&&(ULONG)pNewCursor!=(ULONG)pCursor,"Cursor?")
+ aSelEng.CursorPosChanging( bShift, bMod1 );
+ if( IsEntryInView( pNewCursor ) )
+ SetCursor( pNewCursor );
+ else
+ {
+ SetCursor( pNewCursor );
+ KeyDown( TRUE );
+ }
+ }
+ else
+ KeyDown( FALSE ); // siehe KEY_DOWN
+ }
+ else
+ bKeyUsed = FALSE;
+ break;
+
+ case KEY_SPACE:
+ if( pView->GetSelectionMode() >= MULTIPLE_SELECTION )
+ {
+ if( !bShift && !bMod1 )
+ {
+ if( aSelEng.IsAddMode() )
+ {
+ // toggle selection
+ BOOL bSel = TRUE;
+ if( pView->IsSelected( pCursor ))
+ bSel = FALSE;
+ pView->Select( pCursor, bSel );
+ }
+ else
+ {
+ SelAllDestrAnch( FALSE );
+ pView->Select( pCursor, TRUE );
+ }
+ }
+ }
+ break;
+
+#if 0
+ // Probleme mit Default-OK-Button!
+ case KEY_RETURN:
+ if( pCursor->HasChilds() || pCursor->HasChildsOnDemand() )
+ {
+ if( pView->IsExpanded(pCursor) )
+ pView->Collapse( pCursor );
+ else
+ pView->Expand( pCursor );
+ }
+#endif
+
+ case KEY_F2:
+ if( !bShift && !bMod1 )
+ EditTimerCall( 0 );
+ break;
+
+ case KEY_F8:
+ if( bShift && pView->GetSelectionMode()==MULTIPLE_SELECTION &&
+ !(nWinBits & WB_SIMPLEMODE))
+ {
+ if( aSelEng.IsAlwaysAdding() )
+ aSelEng.AddAlways( FALSE );
+ else
+ aSelEng.AddAlways( TRUE );
+ }
+ break;
+
+
+#ifdef OV_DEBUG
+ case KEY_F9:
+ MakeVisible( pCursor );
+ break;
+ case KEY_F10:
+ pView->RemoveSelection();
+ break;
+ case KEY_DELETE:
+ pView->RemoveEntry( pCursor );
+ break;
+#endif
+
+ case KEY_ADD:
+ if( pCursor )
+ {
+ if( !pView->IsExpanded(pCursor))
+ pView->Expand( pCursor );
+ if( bMod1 )
+ {
+ USHORT nRefDepth = pTree->GetDepth( pCursor );
+ SvLBoxEntry* pCur = pTree->Next( pCursor );
+ while( pCur && pTree->GetDepth(pCur) > nRefDepth )
+ {
+ if( pCur->HasChilds() && !pView->IsExpanded(pCur))
+ pView->Expand( pCur );
+ pCur = pTree->Next( pCur );
+ }
+ }
+ }
+ break;
+
+ case KEY_A:
+ if( bMod1 )
+ SelAllDestrAnch( TRUE );
+ break;
+
+ case KEY_SUBTRACT:
+ if( pCursor )
+ {
+ if( pView->IsExpanded(pCursor))
+ pView->Collapse( pCursor );
+ if( bMod1 )
+ {
+ // bis zur Root alle Parents einklappen
+ SvLBoxEntry* pParentToCollapse = (SvLBoxEntry*)pTree->GetRootLevelParent(pCursor);
+ if( pParentToCollapse )
+ {
+ USHORT nRefDepth;
+ // Sonderbehandlung Explorer: Befindet sich auf der
+ // Root nur ein Eintrag,dann den Root-Entry nicht
+ // einklappen
+ if( pTree->GetChildList(0)->Count() < 2 )
+ {
+ nRefDepth = 1;
+ pParentToCollapse = pCursor;
+ while( pTree->GetParent(pParentToCollapse) &&
+ pTree->GetDepth( pTree->GetParent(pParentToCollapse)) > 0)
+ {
+ pParentToCollapse = pTree->GetParent(pParentToCollapse);
+ }
+ }
+ else
+ nRefDepth = 0;
+
+ if( pView->IsExpanded(pParentToCollapse) )
+ pView->Collapse( pParentToCollapse );
+ SvLBoxEntry* pCur = pTree->Next( pParentToCollapse );
+ while( pCur && pTree->GetDepth(pCur) > nRefDepth )
+ {
+ if( pCur->HasChilds() && pView->IsExpanded(pCur) )
+ pView->Collapse( pCur );
+ pCur = pTree->Next( pCur );
+ }
+ }
+ }
+ }
+ break;
+
+ case KEY_DIVIDE :
+ if( bMod1 )
+ SelAllDestrAnch( TRUE );
+ break;
+
+ case KEY_COMMA :
+ if( bMod1 )
+ SelAllDestrAnch( FALSE );
+ break;
+
+ case KEY_HOME :
+ pNewCursor = pView->GetModel()->First();
+ if( pNewCursor && pNewCursor != pCursor )
+ {
+// SelAllDestrAnch( FALSE );
+ aSelEng.CursorPosChanging( bShift, bMod1 );
+ SetCursor( pNewCursor );
+ if( !IsEntryInView( pNewCursor ) )
+ MakeVisible( pNewCursor );
+ }
+ break;
+
+ case KEY_END :
+ pNewCursor = pView->GetModel()->Last();
+ if( pNewCursor && pNewCursor != pCursor)
+ {
+// SelAllDestrAnch( FALSE );
+ aSelEng.CursorPosChanging( bShift, bMod1 );
+ SetCursor( pNewCursor );
+ if( !IsEntryInView( pNewCursor ) )
+ MakeVisible( pNewCursor );
+ }
+ break;
+
+
+
+ default:
+ bKeyUsed = FALSE;
+ }
+ return bKeyUsed;
+}
+
+void __EXPORT SvImpLBox::GetFocus()
+{
+ if( pCursor )
+ {
+ pView->SetEntryFocus( pCursor, TRUE );
+ ShowCursor( TRUE );
+// auskommentiert wg. deselectall
+// if( bSimpleTravel && !pView->IsSelected(pCursor) )
+// pView->Select( pCursor, TRUE );
+ }
+ if( nWinBits & WB_HIDESELECTION )
+ {
+ SvLBoxEntry* pEntry = pView->FirstSelected();
+ while( pEntry )
+ {
+ SvViewData* pViewData = pView->GetViewData( pEntry );
+ InvalidateEntry( pEntry );
+ pEntry = pView->NextSelected( pEntry );
+ }
+ /*
+ SvLBoxEntry* pEntry = pView->GetModel()->First();
+ while( pEntry )
+ {
+ SvViewData* pViewData = pView->GetViewData( pEntry );
+ if( pViewData->IsCursored() )
+ {
+ pViewData->SetCursored( FALSE );
+ InvalidateEntry( pEntry );
+ }
+ pEntry = pView->GetModel()->Next( pEntry );
+ }
+ */
+
+
+ }
+}
+
+void __EXPORT SvImpLBox::LoseFocus()
+{
+//#if defined(MAC) || defined(OV_DEBUG)
+ aEditTimer.Stop();
+//#endif
+ if( pCursor )
+ pView->SetEntryFocus( pCursor,FALSE );
+ ShowCursor( FALSE );
+
+ if( nWinBits & WB_HIDESELECTION )
+ {
+ SvLBoxEntry* pEntry = pView->FirstSelected();
+ while( pEntry )
+ {
+ SvViewData* pViewData = pView->GetViewData( pEntry );
+ //pViewData->SetCursored( TRUE );
+ InvalidateEntry( pEntry );
+ pEntry = pView->NextSelected( pEntry );
+ }
+ }
+}
+
+
+// ********************************************************************
+// SelectionEngine
+// ********************************************************************
+
+inline void SvImpLBox::SelectEntry( SvLBoxEntry* pEntry, BOOL bSelect )
+{
+ pView->Select( pEntry, bSelect );
+}
+
+__EXPORT ImpLBSelEng::ImpLBSelEng( SvImpLBox* pImpl, SelectionEngine* pSEng,
+ SvTreeListBox* pV )
+{
+ pImp = pImpl;
+ pSelEng = pSEng;
+ pView = pV;
+}
+
+__EXPORT ImpLBSelEng::~ImpLBSelEng()
+{
+}
+
+void __EXPORT ImpLBSelEng::BeginDrag()
+{
+ pImp->BeginDrag();
+}
+
+/*
+void __EXPORT ImpLBSelEng::EndDrag( const Point& )
+{
+}
+*/
+
+void __EXPORT ImpLBSelEng::CreateAnchor()
+{
+ pImp->pAnchor = pImp->pCursor;
+}
+
+void __EXPORT ImpLBSelEng::DestroyAnchor()
+{
+ pImp->pAnchor = 0;
+}
+
+/*
+void __EXPORT ImpLBSelEng::CreateCursor()
+{
+ pImp->pAnchor = 0;
+}
+*/
+
+
+BOOL __EXPORT ImpLBSelEng::SetCursorAtPoint(const Point& rPoint, BOOL bDontSelectAtCursor)
+{
+ SvLBoxEntry* pNewCursor = pImp->MakePointVisible( rPoint );
+ if( pNewCursor != pImp->pCursor )
+ pImp->BeginScroll();
+
+ if( pNewCursor )
+ {
+ // bei SimpleTravel wird in SetCursor selektiert und
+ // der Select-Handler gerufen
+ //if( !bDontSelectAtCursor && !pImp->bSimpleTravel )
+ // pImp->SelectEntry( pNewCursor, TRUE );
+ pImp->SetCursor( pNewCursor, bDontSelectAtCursor );
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL __EXPORT ImpLBSelEng::IsSelectionAtPoint( const Point& rPoint )
+{
+ SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
+ if( pEntry )
+ return pView->IsSelected(pEntry);
+ return FALSE;
+}
+
+void __EXPORT ImpLBSelEng::DeselectAtPoint( const Point& rPoint )
+{
+ SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
+ if( !pEntry )
+ return;
+ pImp->SelectEntry( pEntry, FALSE );
+}
+
+/*
+void __EXPORT ImpLBSelEng::SelectAtPoint( const Point& rPoint )
+{
+ SvLBoxEntry* pEntry = pImp->MakePointVisible( rPoint );
+ if( !pEntry )
+ return;
+ pImp->SelectEntry( pEntry, TRUE );
+}
+*/
+
+void __EXPORT ImpLBSelEng::DeselectAll()
+{
+ pImp->SelAllDestrAnch( FALSE, FALSE ); // SelectionEngine nicht resetten!
+ pImp->nFlags &= (~F_DESEL_ALL);
+}
+
+// ***********************************************************************
+// Selektion
+// ***********************************************************************
+
+void SvImpLBox::SetAnchorSelection(SvLBoxEntry* pOldCursor,SvLBoxEntry* pNewCursor)
+{
+ SvLBoxEntry* pEntry;
+ ULONG nAnchorVisPos = pView->GetVisiblePos( pAnchor );
+ ULONG nOldVisPos = pView->GetVisiblePos( pOldCursor );
+ ULONG nNewVisPos = pView->GetVisiblePos( pNewCursor );
+
+ if( nOldVisPos > nAnchorVisPos ||
+ ( nAnchorVisPos==nOldVisPos && nNewVisPos > nAnchorVisPos) )
+ {
+ if( nNewVisPos > nOldVisPos )
+ {
+ pEntry = pOldCursor;
+ while( pEntry && pEntry != pNewCursor )
+ {
+ pView->Select( pEntry, TRUE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, TRUE );
+ return;
+ }
+
+ if( nNewVisPos < nAnchorVisPos )
+ {
+ pEntry = pAnchor;
+ while( pEntry && pEntry != pOldCursor )
+ {
+ pView->Select( pEntry, FALSE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, FALSE );
+
+ pEntry = pNewCursor;
+ while( pEntry && pEntry != pAnchor )
+ {
+ pView->Select( pEntry, TRUE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, TRUE );
+ return;
+ }
+
+ if( nNewVisPos < nOldVisPos )
+ {
+ pEntry = pNewCursor;
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ while( pEntry && pEntry != pOldCursor )
+ {
+ pView->Select( pEntry, FALSE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, FALSE );
+ return;
+ }
+ }
+ else
+ {
+ if( nNewVisPos < nOldVisPos ) // Vergroessern der Selektion
+ {
+ pEntry = pNewCursor;
+ while( pEntry && pEntry != pOldCursor )
+ {
+ pView->Select( pEntry, TRUE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, TRUE );
+ return;
+ }
+
+ if( nNewVisPos > nAnchorVisPos )
+ {
+ pEntry = pOldCursor;
+ while( pEntry && pEntry != pAnchor )
+ {
+ pView->Select( pEntry, FALSE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, FALSE );
+ pEntry = pAnchor;
+ while( pEntry && pEntry != pNewCursor )
+ {
+ pView->Select( pEntry, TRUE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ if( pEntry )
+ pView->Select( pEntry, TRUE );
+ return;
+ }
+
+ if( nNewVisPos > nOldVisPos )
+ {
+ pEntry = pOldCursor;
+ while( pEntry && pEntry != pNewCursor )
+ {
+ pView->Select( pEntry, FALSE );
+ pEntry = (SvLBoxEntry*)(pView->NextVisible( pEntry ));
+ }
+ return;
+ }
+ }
+}
+
+void SvImpLBox::SelAllDestrAnch( BOOL bSelect, BOOL bDestroyAnchor,
+ BOOL bSingleSelToo )
+{
+ SvLBoxEntry* pEntry;
+ nFlags &= (~F_DESEL_ALL);
+ if( bSelect && bSimpleTravel )
+ {
+ if( pCursor && !pView->IsSelected( pCursor ))
+ {
+ pView->Select( pCursor, TRUE );
+ }
+ return;
+ }
+ if( !bSelect && pView->GetSelectionCount() == 0 )
+ {
+ if( bSimpleTravel && ( !GetUpdateMode() || !pCursor) )
+ nFlags |= F_DESEL_ALL;
+ return;
+ }
+ if( bSelect && pView->GetSelectionCount() == pView->GetEntryCount())
+ return;
+ if( !bSingleSelToo && bSimpleTravel )
+ return;
+
+ if( !bSelect && pView->GetSelectionCount()==1 && pCursor &&
+ pView->IsSelected( pCursor ))
+ {
+ pView->Select( pCursor, FALSE );
+ if( bDestroyAnchor )
+ DestroyAnchor(); // Anker loeschen & SelectionEngine zuruecksetzen
+ else
+ pAnchor = 0; // internen Anker immer loeschen
+ return;
+ }
+
+ if( bSimpleTravel && !pCursor && !GetUpdateMode() )
+ nFlags |= F_DESEL_ALL;
+
+ ShowCursor( FALSE );
+ BOOL bUpdate = GetUpdateMode();
+
+ nFlags |= F_IGNORE_SELECT; // EntryInserted soll nix tun
+ pEntry = pTree->First();
+ while( pEntry )
+ {
+ if( pView->Select( pEntry, bSelect ) )
+ {
+ if( bUpdate && pView->IsEntryVisible(pEntry) )
+ {
+ long nY = GetEntryLine( pEntry );
+ if( IsLineVisible( nY ) )
+ pView->PaintEntry1( pEntry, nY, 0xffff ); // wg. ItemsetBrowser SV_LBOXTAB_SHOW_SELECTION );
+ }
+ }
+ pEntry = pTree->Next( pEntry );
+ }
+ nFlags &= ~F_IGNORE_SELECT;
+
+ if( bDestroyAnchor )
+ DestroyAnchor(); // Anker loeschen & SelectionEngine zuruecksetzen
+ else
+ pAnchor = 0; // internen Anker immer loeschen
+ ShowCursor( TRUE );
+}
+
+void SvImpLBox::SetSelectionMode( SelectionMode eSelMode )
+{
+ aSelEng.SetSelectionMode( eSelMode);
+ if( eSelMode == SINGLE_SELECTION )
+ bSimpleTravel = TRUE;
+ else
+ bSimpleTravel = FALSE;
+ if( (nWinBits & WB_SIMPLEMODE) && (eSelMode == MULTIPLE_SELECTION) )
+ aSelEng.AddAlways( TRUE );
+}
+
+// ***********************************************************************
+// Drag & Drop
+// ***********************************************************************
+
+void SvImpLBox::SetDragDropMode( DragDropMode eDDMode )
+{
+ if( eDDMode && eDDMode != SV_DRAGDROP_APP_DROP )
+ {
+ aSelEng.ExpandSelectionOnMouseMove( FALSE );
+ aSelEng.EnableDrag( TRUE );
+ }
+ else
+ {
+ aSelEng.ExpandSelectionOnMouseMove( TRUE );
+ aSelEng.EnableDrag( FALSE );
+ }
+}
+
+void SvImpLBox::BeginDrag()
+{
+ nFlags &= (~F_FILLING);
+ if( !bAsyncBeginDrag )
+ {
+ BeginScroll();
+ pView->BeginDrag( aSelEng.GetMousePosPixel() );
+ EndScroll();
+ }
+ else
+ {
+ aAsyncBeginDragPos = aSelEng.GetMousePosPixel();
+ aAsyncBeginDragTimer.Start();
+ }
+}
+
+IMPL_LINK( SvImpLBox, BeginDragHdl, void*, EMPTYARG )
+{
+ pView->BeginDrag( aAsyncBeginDragPos );
+ return 0;
+}
+
+void SvImpLBox::PaintDDCursor( SvLBoxEntry* pInsertionPos )
+{
+ long nY;
+ if( pInsertionPos )
+ {
+ nY = GetEntryLine( pInsertionPos );
+ nY += pView->GetEntryHeight();
+ }
+ else
+ nY = 1;
+ RasterOp eOldOp = pView->GetRasterOp();
+ pView->SetRasterOp( ROP_INVERT );
+ Color aOldLineColor = pView->GetLineColor();
+ pView->SetLineColor( Color( COL_BLACK ) );
+ pView->DrawLine( Point( 0, nY ), Point( aOutputSize.Width(), nY ) );
+ pView->SetLineColor( aOldLineColor );
+ pView->SetRasterOp( eOldOp );
+}
+
+void SvImpLBox::Command( const CommandEvent& rCEvt )
+{
+ // Rollmaus-Event?
+ if( (rCEvt.GetCommand() == COMMAND_WHEEL) ||
+ (rCEvt.GetCommand() == COMMAND_STARTAUTOSCROLL) ||
+ (rCEvt.GetCommand() == COMMAND_AUTOSCROLL) )
+ {
+ if( pView->HandleScrollCommand( rCEvt, &aHorSBar, &aVerSBar ) )
+ return;
+ }
+#ifndef NOCOMMAND
+ const Point& rPos = rCEvt.GetMousePosPixel();
+ if( rPos.X() < aOutputSize.Width() && rPos.Y() < aOutputSize.Height() )
+ aSelEng.Command( rCEvt );
+#endif
+}
+
+void SvImpLBox::BeginScroll()
+{
+ if( !(nFlags & F_IN_SCROLLING))
+ {
+ pView->NotifyBeginScroll();
+ nFlags |= F_IN_SCROLLING;
+ }
+}
+
+void SvImpLBox::EndScroll()
+{
+ if( nFlags & F_IN_SCROLLING)
+ {
+ pView->NotifyEndScroll();
+ nFlags &= (~F_IN_SCROLLING);
+ }
+}
+
+
+Rectangle SvImpLBox::GetVisibleArea() const
+{
+ Point aPos( pView->GetMapMode().GetOrigin() );
+ aPos.X() *= -1;
+ Rectangle aRect( aPos, aOutputSize );
+ return aRect;
+}
+
+void SvImpLBox::Invalidate()
+{
+ pView->SetClipRegion();
+}
+
+void SvImpLBox::SetCurEntry( SvLBoxEntry* pEntry )
+{
+ if( aSelEng.GetSelectionMode() != SINGLE_SELECTION )
+ SelAllDestrAnch( FALSE, TRUE, FALSE );
+ MakeVisible( pEntry );
+ SetCursor( pEntry );
+// if( bSimpleTravel )
+ pView->Select( pEntry, TRUE );
+}
+
+//#if defined(MAC) || defined(OV_DEBUG)
+IMPL_LINK( SvImpLBox, EditTimerCall, Timer *, pTimer )
+{
+ if( pView->IsInplaceEditingEnabled() )
+ {
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if( pEntry )
+ {
+ ShowCursor( FALSE );
+ pView->EditEntry( pEntry );
+ ShowCursor( TRUE );
+ }
+ }
+ return 0;
+}
+//#endif
+
+
+BOOL SvImpLBox::RequestHelp( const HelpEvent& rHEvt )
+{
+ if( rHEvt.GetMode() & HELPMODE_QUICK )
+ {
+ Point aPos( pView->ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
+ if( !GetVisibleArea().IsInside( aPos ))
+ return FALSE;
+
+ SvLBoxEntry* pEntry = GetEntry( aPos );
+ if( pEntry )
+ {
+ // Rechteck des Textes berechnen
+ SvLBoxTab* pTab;
+ SvLBoxString* pItem = (SvLBoxString*)(pView->GetItem( pEntry, aPos.X(), &pTab ));
+ if( !pItem || pItem->IsA() != SV_ITEM_ID_LBOXSTRING )
+ return FALSE;
+
+ aPos = GetEntryPos( pEntry );
+ aPos.X() = pView->GetTabPos( pEntry, pTab ); //pTab->GetPos();
+ Size aSize( pItem->GetSize( pView, pEntry ) );
+ SvLBoxTab* pNextTab = NextTab( pTab );
+ BOOL bItemClipped = FALSE;
+ // wurde das Item von seinem rechten Nachbarn abgeschnitten?
+ if( pNextTab && pView->GetTabPos(pEntry,pNextTab) < aPos.X()+aSize.Width() )
+ {
+ aSize.Width() = pNextTab->GetPos() - pTab->GetPos();
+ bItemClipped = TRUE;
+ }
+ Rectangle aItemRect( aPos, aSize );
+
+ Rectangle aViewRect( GetVisibleArea() );
+
+ if( bItemClipped || !aViewRect.IsInside( aItemRect ) )
+ {
+ // rechten Item-Rand am View-Rand clippen
+ //if( aItemRect.Right() > aViewRect.Right() )
+ // aItemRect.Right() = aViewRect.Right();
+
+ Point aPt = pView->OutputToScreenPixel( aItemRect.TopLeft() );
+ aItemRect.Left() = aPt.X();
+ aItemRect.Top() = aPt.Y();
+ aPt = pView->OutputToScreenPixel( aItemRect.BottomRight() );
+ aItemRect.Right() = aPt.X();
+ aItemRect.Bottom() = aPt.Y();
+
+ Help::ShowQuickHelp( pView, aItemRect,
+ pItem->GetText(), QUICKHELP_LEFT | QUICKHELP_VCENTER );
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+SvLBoxTab* SvImpLBox::NextTab( SvLBoxTab* pTab )
+{
+ USHORT nTabCount = pView->TabCount();
+ if( nTabCount <= 1 )
+ return 0;
+ for( USHORT nTab=0; nTab < (nTabCount-1); nTab++)
+ {
+ if( pView->aTabs[nTab]==pTab )
+ return (SvLBoxTab*)(pView->aTabs[nTab+1]);
+ }
+ return 0;
+}
+
+void SvImpLBox::EndSelection()
+{
+ DestroyAnchor();
+ nFlags &= ~F_START_EDITTIMER;
+}
+
+void SvImpLBox::RepaintScrollBars()
+{
+#ifndef VCL
+ aHorSBar.Invalidate();
+ aHorSBar.Update();
+ aVerSBar.Invalidate();
+ aVerSBar.Update();
+#endif
+}
+
+void SvImpLBox::SetUpdateMode( BOOL bMode )
+{
+ if( bUpdateMode != bMode )
+ {
+ bUpdateMode = bMode;
+ if( bUpdateMode )
+ UpdateAll( FALSE );
+ }
+}
+
+void SvImpLBox::SetUpdateModeFast( BOOL bMode )
+{
+ if( bUpdateMode != bMode )
+ {
+ bUpdateMode = bMode;
+ if( bUpdateMode )
+ UpdateAll( FALSE, FALSE );
+ }
+}
+
+
+BOOL SvImpLBox::SetMostRight( SvLBoxEntry* pEntry )
+{
+ if( pView->nTreeFlags & TREEFLAG_RECALCTABS )
+ {
+ nFlags |= F_IGNORE_CHANGED_TABS;
+ pView->SetTabs();
+ nFlags &= ~F_IGNORE_CHANGED_TABS;
+ }
+
+ USHORT nLastTab = pView->aTabs.Count() - 1;
+ USHORT nLastItem = pEntry->ItemCount() - 1;
+ if( nLastTab != USHRT_MAX && nLastItem != USHRT_MAX )
+ {
+ if( nLastItem < nLastTab )
+ nLastTab = nLastItem;
+
+ SvLBoxTab* pTab = (SvLBoxTab*)pView->aTabs[ nLastTab ];
+ SvLBoxItem* pItem = pEntry->GetItem( nLastTab );
+
+ long nTabPos = pView->GetTabPos( pEntry, pTab );
+
+ long nMaxRight = GetOutputSize().Width();
+ Point aPos( pView->GetMapMode().GetOrigin() );
+ aPos.X() *= -1; // Umrechnung Dokumentkoord.
+ nMaxRight = nMaxRight + aPos.X() - 1;
+
+ long nNextTab = nTabPos < nMaxRight ? nMaxRight : nMaxRight + 50;
+ long nTabWidth = nNextTab - nTabPos + 1;
+ long nItemSize = pItem->GetSize(pView,pEntry).Width();
+ long nOffset = pTab->CalcOffset( nItemSize, nTabWidth );
+
+ long nRight = nTabPos + nOffset + nItemSize;
+ if( nRight > nMostRight )
+ {
+ nMostRight = nRight;
+ pMostRightEntry = pEntry;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void SvImpLBox::FindMostRight( SvLBoxEntry* pEntryToIgnore )
+{
+ nMostRight = -1;
+ pMostRightEntry = 0;
+ if( !pView->GetModel() )
+ return;
+
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pView->FirstVisible();
+ while( pEntry )
+ {
+ if( pEntry != pEntryToIgnore )
+ SetMostRight( pEntry );
+ pEntry = (SvLBoxEntry*)pView->NextVisible( pEntry );
+ }
+}
+
+void SvImpLBox::FindMostRight( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToIgnore )
+{
+ if( !pParent )
+ FindMostRight( pEntryToIgnore );
+ else
+ FindMostRight_Impl( pParent, pEntryToIgnore );
+}
+
+void SvImpLBox::FindMostRight_Impl( SvLBoxEntry* pParent, SvLBoxEntry* pEntryToIgnore )
+{
+ SvTreeEntryList* pList = pTree->GetChildList( pParent );
+
+ if( !pList )
+ return;
+
+ ULONG nCount = pList->Count();
+ for( ULONG nCur = 0; nCur < nCount; nCur++ )
+ {
+ SvLBoxEntry* pChild = (SvLBoxEntry*)pList->GetObject( nCur );
+ if( pChild != pEntryToIgnore )
+ {
+ SetMostRight( pChild );
+ if( pChild->HasChilds() && pView->IsExpanded( pChild ))
+ FindMostRight_Impl( pChild, pEntryToIgnore );
+ }
+ }
+}
+
+void SvImpLBox::NotifyTabsChanged()
+{
+ if( GetUpdateMode() && !(nFlags & F_IGNORE_CHANGED_TABS ) &&
+ nCurUserEvent == 0xffffffff )
+ {
+ nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpLBox,MyUserEvent),(void*)0);
+ }
+}
+
+IMPL_LINK(SvImpLBox,MyUserEvent,void*, pArg )
+{
+ nCurUserEvent = 0xffffffff;
+ if( !pArg )
+ {
+ pView->Invalidate();
+ pView->Update();
+ }
+ else
+ {
+ FindMostRight( 0 );
+ ShowVerSBar();
+ pView->Invalidate( GetVisibleArea() );
+ }
+ return 0;
+}
+
+
+void SvImpLBox::StopUserEvent()
+{
+ if( nCurUserEvent != 0xffffffff )
+ {
+ Application::RemoveUserEvent( nCurUserEvent );
+ nCurUserEvent = 0xffffffff;
+ }
+}
+
+void SvImpLBox::ShowFocusRect( const SvLBoxEntry* pEntry )
+{
+ if( pEntry )
+ {
+ long nY = GetEntryLine( (SvLBoxEntry*)pEntry );
+ Rectangle aRect = pView->GetFocusRect( (SvLBoxEntry*)pEntry, nY );
+ Region aOldClip( pView->GetClipRegion());
+ Region aClipRegion( GetClipRegionRect() );
+ pView->SetClipRegion( aClipRegion );
+ pView->ShowFocus( aRect );
+ pView->SetClipRegion( aOldClip );
+
+ }
+ else
+ {
+ pView->HideFocus();
+ }
+}
+
+void SvImpLBox::SetTabBar( TabBar* _pTabBar )
+{
+ pTabBar = _pTabBar;
+}
+
+
diff --git a/svtools/source/contnr/svimpicn.cxx b/svtools/source/contnr/svimpicn.cxx
new file mode 100644
index 000000000000..5d0f83c01d78
--- /dev/null
+++ b/svtools/source/contnr/svimpicn.cxx
@@ -0,0 +1,4222 @@
+/*************************************************************************
+ *
+ * $RCSfile: svimpicn.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:56 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#include <limits.h>
+#ifndef _METRIC_HXX
+#include <vcl/metric.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifdef DBG_UTIL
+#include <vcl/sound.hxx>
+#endif
+
+#pragma hdrstop
+
+#include <svlbox.hxx>
+#include <svicnvw.hxx>
+#ifndef _SVIMPICN_HXX
+#include <svimpicn.hxx>
+#endif
+#ifndef _SVLBITM_HXX
+#include <svlbitm.hxx>
+#endif
+#ifndef _SVARRAY_HXX
+#include "svarray.hxx"
+#endif
+
+
+
+#define VIEWMODE_ICON 0x0001 // Text unter Bitmap
+#define VIEWMODE_NAME 0x0002 // Text rechts neben Bitmap
+#define VIEWMODE_TEXT 0x0004 // Text ohne Bitmap
+
+#define DD_SCROLL_PIXEL 10
+
+// alle Angaben in Pixel
+
+#define ICONVIEW_OFFS_BMP_STRING 3
+
+// fuer das Bounding-Rectangle
+#define LROFFS_BOUND 2
+#define TBOFFS_BOUND 2
+
+// fuer das Focus-Rectangle um Icons
+#define LROFFS_ICON 2
+#define TBOFFS_ICON 2
+
+#define NAMEVIEW_OFFS_BMP_STRING 3
+
+// Abstaende von Fensterraendern
+#define LROFFS_WINBORDER 4
+#define TBOFFS_WINBORDER 4
+
+// Breitenoffset Highlight-Rect bei Text
+#define LROFFS_TEXT 2
+
+
+#define ICNVIEWDATA(xPtr) (SvIcnVwDataEntry*)(pView->GetViewDataEntry(xPtr))
+#define ICNVIEWDATA2(xPtr) (SvIcnVwDataEntry*)(pView->pView->GetViewDataEntry(xPtr))
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+// Hilfsfunktionen von Thomas Hosemann zur mehrzeiligen Ausgabe von
+// Strings. Die Funktionen werden spaeter in StarView integriert.
+// -------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+// keine doppelten Defines
+#ifdef TEXT_DRAW_CLIP
+#undef TEXT_DRAW_CLIP
+#endif
+#ifdef TEXT_DRAW_MULTILINE
+#undef TEXT_DRAW_MULTILINE
+#endif
+#ifdef TEXT_DRAW_WORDBREAK
+#undef TEXT_DRAW_WORDBREAK
+#endif
+
+// #define TEXT_DRAW_DISABLE ((USHORT)0x0001)
+// #define TEXT_DRAW_3DLOOK ((USHORT)0x0002)
+// #define TEXT_DRAW_MNEMONIC ((USHORT)0x0004)
+#define TEXT_DRAW_LEFT ((USHORT)0x0010)
+#define TEXT_DRAW_CENTER ((USHORT)0x0020)
+#define TEXT_DRAW_RIGHT ((USHORT)0x0040)
+#define TEXT_DRAW_TOP ((USHORT)0x0080)
+#define TEXT_DRAW_VCENTER ((USHORT)0x0100)
+#define TEXT_DRAW_BOTTOM ((USHORT)0x0200)
+#define TEXT_DRAW_ENDELLIPSIS ((USHORT)0x0400)
+#define TEXT_DRAW_PATHELLIPSIS ((USHORT)0x0800)
+#define TEXT_DRAW_CLIP ((USHORT)0x1000)
+#define TEXT_DRAW_MULTILINE ((USHORT)0x2000)
+#define TEXT_DRAW_WORDBREAK ((USHORT)0x4000)
+
+XubString GetEllipsisString( OutputDevice* pDev,
+ const XubString& rStr, long nMaxWidth,
+ USHORT nStyle = TEXT_DRAW_ENDELLIPSIS )
+{
+ XubString aStr = rStr;
+
+ if ( nStyle & TEXT_DRAW_ENDELLIPSIS )
+ {
+ USHORT nIndex = pDev->GetTextBreak( rStr, nMaxWidth );
+ if ( nIndex != STRING_LEN )
+ {
+ aStr.Erase( nIndex );
+ if ( nIndex > 1 )
+ {
+ aStr.AppendAscii("...");
+ while ( aStr.Len() &&
+ (pDev->GetTextWidth( aStr ) > nMaxWidth) )
+ {
+ if ( (nIndex > 1) || (nIndex == aStr.Len()) )
+ nIndex--;
+ aStr.Erase( nIndex, 1 );
+ }
+ }
+
+ if ( !aStr.Len() && (nStyle & TEXT_DRAW_CLIP) )
+ aStr += rStr.GetChar( 0 );
+ }
+ }
+
+ return aStr;
+}
+
+class TextLineInfo
+{
+private:
+ long mnWidth;
+ USHORT mnIndex;
+ USHORT mnLen;
+
+public:
+ TextLineInfo( long nWidth, USHORT nIndex, USHORT nLen )
+ {
+ mnWidth = nWidth;
+ mnIndex = nIndex;
+ mnLen = nLen;
+ }
+
+ long GetWidth() const { return mnWidth; }
+ USHORT GetIndex() const { return mnIndex; }
+ USHORT GetLen() const { return mnLen; }
+};
+
+#define MULTITEXTLINEINFO_RESIZE 16
+typedef TextLineInfo* PTextLineInfo;
+
+class MultiTextLineInfo
+{
+private:
+ PTextLineInfo* mpLines;
+ USHORT mnLines;
+ USHORT mnSize;
+
+public:
+ MultiTextLineInfo();
+ ~MultiTextLineInfo();
+
+ void AddLine( TextLineInfo* pLine );
+ void Clear();
+
+ TextLineInfo* GetLine( USHORT nLine ) const
+ { return mpLines[nLine]; }
+ USHORT Count() const { return mnLines; }
+
+private:
+ MultiTextLineInfo( const MultiTextLineInfo& );
+ MultiTextLineInfo& operator=( const MultiTextLineInfo& );
+};
+
+MultiTextLineInfo::MultiTextLineInfo()
+{
+ mpLines = new PTextLineInfo[MULTITEXTLINEINFO_RESIZE];
+ mnLines = 0;
+ mnSize = MULTITEXTLINEINFO_RESIZE;
+}
+
+MultiTextLineInfo::~MultiTextLineInfo()
+{
+ for ( USHORT i = 0; i < mnLines; i++ )
+ delete mpLines[i];
+ delete mpLines;
+}
+
+void MultiTextLineInfo::AddLine( TextLineInfo* pLine )
+{
+ if ( mnSize == mnLines )
+ {
+ mnSize += MULTITEXTLINEINFO_RESIZE;
+ PTextLineInfo* pNewLines = new PTextLineInfo[mnSize];
+ memcpy( pNewLines, mpLines, mnLines*sizeof(PTextLineInfo) );
+ mpLines = pNewLines;
+ }
+
+ mpLines[mnLines] = pLine;
+ mnLines++;
+}
+
+void MultiTextLineInfo::Clear()
+{
+ for ( USHORT i = 0; i < mnLines; i++ )
+ delete mpLines[i];
+ mnLines = 0;
+}
+
+// -----------------------------------------------------------------------
+
+long GetTextLines( OutputDevice* pDev, MultiTextLineInfo& rLineInfo,
+ long nWidth, const XubString& rStr,
+ USHORT nStyle = TEXT_DRAW_WORDBREAK )
+{
+ rLineInfo.Clear();
+ if ( !rStr.Len() )
+ return 0;
+ if ( nWidth <= 0 )
+ nWidth = 1;
+
+ USHORT nStartPos = 0; // Start-Position der Zeile
+ USHORT nLastLineLen = 0; // Zeilenlaenge bis zum vorherigen Wort
+ USHORT nLastWordPos = 0; // Position des letzten Wortanfangs
+ USHORT i = 0;
+ USHORT nPos; // StartPositon der Zeile (nur Temp)
+ USHORT nLen; // Laenge der Zeile (nur Temp)
+ USHORT nStrLen = rStr.Len();
+ long nMaxLineWidth = 0; // Maximale Zeilenlaenge
+ long nLineWidth; // Aktuelle Zeilenlaenge
+ long nLastLineWidth = 0; // Zeilenlaenge der letzten Zeile
+ xub_Unicode c;
+ xub_Unicode c2;
+ const xub_Unicode* pStr = rStr.GetBuffer();
+ BOOL bHardBreak = FALSE;
+
+ do
+ {
+ c = pStr[i];
+
+ // Auf Zeilenende ermitteln
+ if ( (c == _CR) || (c == _LF) )
+ bHardBreak = TRUE;
+ else
+ bHardBreak = FALSE;
+
+ // Testen, ob ein Wortende erreicht ist
+ if ( bHardBreak || (i == nStrLen) ||
+ (((c == ' ') || (c == '-')) && (nStyle & TEXT_DRAW_WORDBREAK)) )
+ {
+ nLen = i-nStartPos;
+ if ( c == '-' )
+ nLen++;
+ nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLen );
+
+ // Findet ein Zeilenumbruch statt
+ if ( bHardBreak || (i == nStrLen) ||
+ ((nLineWidth >= nWidth) && (nStyle & TEXT_DRAW_WORDBREAK)) )
+ {
+ nPos = nStartPos;
+
+ if ( (nLineWidth >= nWidth) && (nStyle & TEXT_DRAW_WORDBREAK) )
+ {
+ nLineWidth = nLastLineWidth;
+ nLen = nLastLineLen;
+ nStartPos = nLastWordPos;
+ nLastLineLen = i-nStartPos;
+ nLastWordPos = nStartPos+nLastLineLen+1;
+ if ( c == '-' )
+ nLastLineLen++;
+ else if ( bHardBreak && (i > nStartPos) )
+ i--;
+ }
+ else
+ {
+ nStartPos = i;
+ // Zeilenende-Zeichen und '-' beruecksichtigen
+ if ( bHardBreak )
+ {
+ nStartPos++;
+ c2 = pStr[i+1];
+ if ( (c != c2) && ((c2 == _CR) || (c2 == _LF)) )
+ {
+ nStartPos++;
+ i++;
+ }
+ }
+ else if ( c != '-' )
+ nStartPos++;
+ nLastWordPos = nStartPos;
+ nLastLineLen = 0;
+ }
+
+ if ( nLineWidth > nMaxLineWidth )
+ nMaxLineWidth = nLineWidth;
+
+ if ( nLen || bHardBreak )
+ rLineInfo.AddLine( new TextLineInfo( nLineWidth, nPos, nLen ) );
+
+ // Testen, ob aktuelles Wort noch auf die Zeile passt,
+ // denn ansonsten mueessen wir es auftrennen
+ if ( nLastLineLen )
+ {
+ nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLastLineLen );
+ if ( nLineWidth > nWidth )
+ {
+ // Wenn ein Wortumbruch in einem Wort stattfindet,
+ // ist die maximale Zeilenlaenge die Laenge
+ // des laengsten Wortes
+ if ( nLineWidth > nMaxLineWidth )
+ nMaxLineWidth = nLineWidth;
+
+ // Solange Wort auftrennen, bis es auf eine Zeile passt
+ do
+ {
+ nPos = pDev->GetTextBreak( rStr, nWidth, nStartPos, nLastLineLen );
+ nLen = nPos-nStartPos;
+ if ( !nLen )
+ {
+ nPos++;
+ nLen++;
+ }
+ nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLen );
+ rLineInfo.AddLine( new TextLineInfo( nLineWidth, nStartPos, nLen ) );
+ nStartPos = nPos;
+ nLastLineLen -= nLen;
+ nLineWidth = pDev->GetTextWidth( rStr, nStartPos, nLastLineLen );
+ }
+ while ( nLineWidth > nWidth );
+ }
+ nLastLineWidth = nLineWidth;
+
+ // Bei Stringende muessen wir die letzte Zeile auch noch
+ // dranhaengen
+ if ( (i == nStrLen) && nLastLineLen )
+ rLineInfo.AddLine( new TextLineInfo( nLastLineWidth, nStartPos, nLastLineLen ) );
+ }
+ else
+ nLastLineWidth = 0;
+ }
+ else
+ {
+ nLastLineWidth = nLineWidth;
+ nLastLineLen = nLen;
+ nLastWordPos = nStartPos+nLastLineLen;
+ if ( c != '-' )
+ nLastWordPos++;
+ }
+ }
+
+ i++;
+ }
+ while ( i <= nStrLen );
+
+ return nMaxLineWidth;
+}
+
+// -----------------------------------------------------------------------
+
+USHORT GetTextLines( OutputDevice* pDev, const Rectangle& rRect,
+ const XubString& rStr,
+ USHORT nStyle = TEXT_DRAW_WORDBREAK,
+ long* pMaxWidth = NULL )
+{
+ MultiTextLineInfo aMultiLineInfo;
+ long nMaxWidth = GetTextLines( pDev, aMultiLineInfo,
+ rRect.GetWidth(), rStr, nStyle );
+ if ( pMaxWidth )
+ *pMaxWidth = nMaxWidth;
+ return aMultiLineInfo.Count();
+}
+
+// -----------------------------------------------------------------------
+
+Rectangle GetTextRect( OutputDevice* pDev, const Rectangle& rRect,
+ const XubString& rStr,
+ USHORT nStyle = TEXT_DRAW_WORDBREAK )
+{
+ Rectangle aRect = rRect;
+ USHORT nLines;
+ long nWidth = rRect.GetWidth();
+ long nMaxWidth;
+ long nTextHeight;
+
+ if ( nStyle & TEXT_DRAW_MULTILINE )
+ {
+ MultiTextLineInfo aMultiLineInfo;
+ TextLineInfo* pLineInfo;
+ USHORT nFormatLines;
+
+ nMaxWidth = 0;
+ GetTextLines( pDev, aMultiLineInfo, nWidth, rStr, nStyle );
+ nFormatLines = aMultiLineInfo.Count();
+ nTextHeight = pDev->GetTextHeight();
+ nLines = (USHORT)(aRect.GetHeight()/nTextHeight);
+ if ( nFormatLines <= nLines )
+ nLines = nFormatLines;
+ else
+ {
+ if ( !(nStyle & TEXT_DRAW_ENDELLIPSIS) )
+ nLines = nFormatLines;
+ else
+ nMaxWidth = nWidth;
+ }
+ for ( USHORT i = 0; i < nLines; i++ )
+ {
+ pLineInfo = aMultiLineInfo.GetLine( i );
+ if ( pLineInfo->GetWidth() > nMaxWidth )
+ nMaxWidth = pLineInfo->GetWidth();
+ }
+ }
+ else
+ {
+ nLines = 1;
+ nMaxWidth = pDev->GetTextWidth( rStr );
+ nTextHeight = pDev->GetTextHeight();
+ if ( (nMaxWidth > nWidth) && (nStyle & TEXT_DRAW_ENDELLIPSIS) )
+ nMaxWidth = nWidth;
+ }
+
+ if ( nStyle & TEXT_DRAW_RIGHT )
+ aRect.Left() = aRect.Right()-nMaxWidth+1;
+ else if ( nStyle & TEXT_DRAW_CENTER )
+ {
+ aRect.Left() += (nWidth-nMaxWidth)/2;
+ aRect.Right() = aRect.Left()+nMaxWidth-1;
+ }
+ else
+ aRect.Right() = aRect.Left()+nMaxWidth-1;
+
+ if ( nStyle & TEXT_DRAW_BOTTOM )
+ aRect.Top() = aRect.Bottom()-(nTextHeight*nLines)+1;
+ else if ( nStyle & TEXT_DRAW_VCENTER )
+ {
+ aRect.Top() += (aRect.GetHeight()-(nTextHeight*nLines))/2;
+ aRect.Bottom() = aRect.Top()+(nTextHeight*nLines)-1;
+ }
+ else
+ aRect.Bottom() = aRect.Top()+(nTextHeight*nLines)-1;
+
+ return aRect;
+}
+
+// -----------------------------------------------------------------------
+
+void DrawText( OutputDevice* pDev, const Rectangle& rRect,
+ const XubString& rStr, USHORT nStyle = 0 )
+{
+ if ( !rStr.Len() || rRect.IsEmpty() )
+ return;
+
+ Point aPos = rRect.TopLeft();
+ long nWidth = rRect.GetWidth();
+ long nHeight = rRect.GetHeight();
+ FontAlign eAlign = pDev->GetFont().GetAlign();
+
+ if ( ((nWidth <= 0) || (nHeight <= 0)) && (nStyle & TEXT_DRAW_CLIP) )
+ return;
+
+ // Mehrzeiligen Text behandeln wir anders
+ if ( nStyle & TEXT_DRAW_MULTILINE )
+ {
+ String aLastLine;
+ Region aOldRegion;
+ MultiTextLineInfo aMultiLineInfo;
+ TextLineInfo* pLineInfo;
+ long nTextHeight = pDev->GetTextHeight();
+ long nMaxTextWidth;
+ USHORT i;
+ USHORT nLines = (USHORT)(nHeight/nTextHeight);
+ USHORT nFormatLines;
+ BOOL bIsClipRegion;
+ nMaxTextWidth = GetTextLines( pDev, aMultiLineInfo, nWidth, rStr, nStyle );
+
+ nFormatLines = aMultiLineInfo.Count();
+ if ( nFormatLines > nLines )
+ {
+ if ( nStyle & TEXT_DRAW_ENDELLIPSIS )
+ {
+ // Letzte Zeile zusammenbauen und kuerzen
+ nFormatLines = nLines-1;
+ pLineInfo = aMultiLineInfo.GetLine( nFormatLines );
+ aLastLine = rStr.Copy( pLineInfo->GetIndex() );
+ aLastLine.ConvertLineEnd( LINEEND_LF );
+ aLastLine.SearchAndReplace( _LF, ' ' );
+ aLastLine = GetEllipsisString( pDev, aLastLine, nWidth, nStyle );
+ nStyle &= ~(TEXT_DRAW_VCENTER | TEXT_DRAW_BOTTOM);
+ nStyle |= TEXT_DRAW_TOP;
+ }
+ }
+ else
+ {
+ if ( nMaxTextWidth <= nWidth )
+ nStyle &= ~TEXT_DRAW_CLIP;
+ }
+
+ // Clipping setzen
+ if ( nStyle & TEXT_DRAW_CLIP )
+ {
+ bIsClipRegion = pDev->IsClipRegion();
+ if ( bIsClipRegion )
+ {
+ aOldRegion = pDev->GetClipRegion();
+ pDev->IntersectClipRegion( rRect );
+ }
+ else
+ {
+ Region aRegion( rRect );
+ pDev->SetClipRegion( aRegion );
+ }
+ }
+
+ // Vertikales Alignment
+ if ( nStyle & TEXT_DRAW_BOTTOM )
+ aPos.Y() += nHeight-(nFormatLines*nTextHeight);
+ else if ( nStyle & TEXT_DRAW_VCENTER )
+ aPos.Y() += (nHeight-(nFormatLines*nTextHeight))/2;
+
+ // Font Alignment
+ if ( eAlign == ALIGN_BOTTOM )
+ aPos.Y() += nTextHeight;
+ else if ( eAlign == ALIGN_BASELINE )
+ aPos.Y() += pDev->GetFontMetric().GetAscent();
+
+ // Alle Zeilen ausgeben, bis auf die letzte
+ for ( i = 0; i < nFormatLines; i++ )
+ {
+ pLineInfo = aMultiLineInfo.GetLine( i );
+ if ( nStyle & TEXT_DRAW_RIGHT )
+ aPos.X() += nWidth-pLineInfo->GetWidth();
+ else if ( nStyle & TEXT_DRAW_CENTER )
+ aPos.X() += (nWidth-pLineInfo->GetWidth())/2;
+ pDev->DrawText( aPos, rStr, pLineInfo->GetIndex(), pLineInfo->GetLen() );
+ aPos.Y() += nTextHeight;
+ aPos.X() = rRect.Left();
+ }
+
+ // Gibt es noch eine letzte Zeile, dann diese linksbuendig ausgeben,
+ // da die Zeile gekuerzt wurde
+ if ( aLastLine.Len() )
+ pDev->DrawText( aPos, aLastLine );
+
+ // Clipping zuruecksetzen
+ if ( nStyle & TEXT_DRAW_CLIP )
+ {
+ if ( bIsClipRegion )
+ pDev->SetClipRegion( aOldRegion );
+ else
+ pDev->SetClipRegion();
+ }
+ }
+ else
+ {
+ XubString aStr = rStr;
+ Size aTextSize(pDev->GetTextWidth( aStr ), pDev->GetTextHeight());
+
+ // Evt. Text kuerzen
+ if ( aTextSize.Width() > nWidth )
+ {
+ if ( nStyle & TEXT_DRAW_ENDELLIPSIS )
+ {
+ aStr = GetEllipsisString( pDev, rStr, nWidth, nStyle );
+ nStyle &= ~(TEXT_DRAW_CENTER | TEXT_DRAW_RIGHT);
+ nStyle |= TEXT_DRAW_LEFT;
+ aTextSize.Width() = pDev->GetTextWidth(aStr);
+ }
+ }
+ else
+ {
+ if ( aTextSize.Height() <= nHeight )
+ nStyle &= ~TEXT_DRAW_CLIP;
+ }
+
+ // Vertikales Alignment
+ if ( nStyle & TEXT_DRAW_RIGHT )
+ aPos.X() += nWidth-aTextSize.Width();
+ else if ( nStyle & TEXT_DRAW_CENTER )
+ aPos.X() += (nWidth-aTextSize.Width())/2;
+
+ // Font Alignment
+ if ( eAlign == ALIGN_BOTTOM )
+ aPos.Y() += aTextSize.Height();
+ else if ( eAlign == ALIGN_BASELINE )
+ aPos.Y() += pDev->GetFontMetric().GetAscent();
+
+ if ( nStyle & TEXT_DRAW_BOTTOM )
+ aPos.Y() += nHeight-aTextSize.Height();
+ else if ( nStyle & TEXT_DRAW_VCENTER )
+ aPos.Y() += (nHeight-aTextSize.Height())/2;
+
+ if ( nStyle & TEXT_DRAW_CLIP )
+ {
+ BOOL bIsClipRegion = pDev->IsClipRegion();
+ if ( bIsClipRegion )
+ {
+ Region aOldRegion = pDev->GetClipRegion();
+ pDev->IntersectClipRegion( rRect );
+ pDev->DrawText( aPos, aStr );
+ pDev->SetClipRegion( aOldRegion );
+ }
+ else
+ {
+ Region aRegion( rRect );
+ pDev->SetClipRegion( aRegion );
+ pDev->DrawText( aPos, aStr );
+ pDev->SetClipRegion();
+ }
+ }
+ else
+ pDev->DrawText( aPos, aStr );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+//--------------------------------------------------------------------------
+
+
+#define DRAWTEXT_FLAGS (TEXT_DRAW_CENTER|TEXT_DRAW_TOP|TEXT_DRAW_ENDELLIPSIS|\
+ TEXT_DRAW_CLIP|TEXT_DRAW_MULTILINE|TEXT_DRAW_WORDBREAK)
+
+
+class ImpIcnCursor
+{
+ SvImpIconView* pView;
+ SvPtrarr* pColumns;
+ SvPtrarr* pRows;
+ BOOL* pGridMap;
+ long nGridDX, nGridDY;
+ long nGridCols, nGridRows;
+ long nCols;
+ long nRows;
+ short nDeltaWidth;
+ short nDeltaHeight;
+ SvLBoxEntry* pCurEntry;
+ void SetDeltas();
+ void ImplCreate();
+ void Create() { if( !pColumns ) ImplCreate(); }
+
+ USHORT GetSortListPos( SvPtrarr* pList, long nValue, int bVertical);
+ SvLBoxEntry* SearchCol(USHORT nCol,USHORT nTop,USHORT nBottom,USHORT nPref,
+ BOOL bDown, BOOL bSimple );
+ SvLBoxEntry* SearchRow(USHORT nRow,USHORT nRight,USHORT nLeft,USHORT nPref,
+ BOOL bRight, BOOL bSimple );
+
+ void ExpandGrid();
+ void CreateGridMap();
+ // Rueckgabe FALSE: Eintrag liegt nicht in der GridMap. rGridx,y werden
+ // dann an nGridCols, nGridRows geclippt
+ BOOL GetGrid( const Point& rDocPos, USHORT& rGridX, USHORT& rGridY ) const;
+ void SetGridUsed( USHORT nDX, USHORT nDY, BOOL bUsed )
+ {
+ pGridMap[ (nDY * nGridCols) + nDX ] = bUsed;
+ }
+ BOOL IsGridUsed( USHORT nDX, USHORT nDY )
+ {
+ return pGridMap[ (nDY * nGridCols) + nDX ];
+ }
+public:
+ ImpIcnCursor( SvImpIconView* pOwner );
+ ~ImpIcnCursor();
+ void Clear( BOOL bGridToo = TRUE );
+
+ // fuer Cursortravelling usw.
+ SvLBoxEntry* GoLeftRight( SvLBoxEntry*, BOOL bRight );
+ SvLBoxEntry* GoUpDown( SvLBoxEntry*, BOOL bDown );
+
+ // Rueckgaebe: FALSE == Das leere Rect steht hinter dem letzten
+ // Eintrag; d.h. beim naechsten Einfuegen ergibt sich das naechste
+ // leere Rechteck durch Addition. Hinweis: Das Rechteck kann dann
+ // ausserhalb des View-Space liegen
+ BOOL FindEmptyGridRect( Rectangle& rRect );
+
+ // Erzeugt fuer jede Zeile (Hoehe=nGridDY) eine nach BoundRect.Left()
+ // sortierte Liste der Eintraege, die in ihr stehen. Eine Liste kann
+ // leer sein. Die Listen gehen in das Eigentum des Rufenden ueber und
+ // muessen mit DestroyGridAdjustData geloescht werden
+ void CreateGridAjustData( SvPtrarr& pLists, SvLBoxEntry* pRow=0);
+ static void DestroyGridAdjustData( SvPtrarr& rLists );
+ void SetGridUsed( const Rectangle&, BOOL bUsed = TRUE );
+};
+
+
+
+
+SvImpIconView::SvImpIconView( SvIconView* pCurView, SvLBoxTreeList* pTree,
+ WinBits nWinStyle ) :
+ aVerSBar( pCurView, WB_DRAG | WB_VSCROLL ),
+ aHorSBar( pCurView, WB_DRAG | WB_HSCROLL )
+{
+ pView = pCurView;
+ pModel = pTree;
+ pCurParent = 0;
+ pZOrderList = new SvPtrarr;
+ SetWindowBits( nWinStyle );
+ nHorDist = 0;
+ nVerDist = 0;
+ nFlags = 0;
+ nCurUserEvent = 0;
+ nMaxVirtWidth = 200;
+ pDDRefEntry = 0;
+ pDDDev = 0;
+ pDDBufDev = 0;
+ pDDTempDev = 0;
+ eTextMode = ShowTextShort;
+ pImpCursor = new ImpIcnCursor( this );
+
+ aVerSBar.SetScrollHdl( LINK( this, SvImpIconView, ScrollUpDownHdl ) );
+ aHorSBar.SetScrollHdl( LINK( this, SvImpIconView, ScrollLeftRightHdl ) );
+ nHorSBarHeight = aHorSBar.GetSizePixel().Height();
+ nVerSBarWidth = aVerSBar.GetSizePixel().Width();
+
+ aMouseMoveTimer.SetTimeout( 20 );
+ aMouseMoveTimer.SetTimeoutHdl(LINK(this,SvImpIconView,MouseMoveTimeoutHdl));
+
+ aEditTimer.SetTimeout( 800 );
+ aEditTimer.SetTimeoutHdl(LINK(this,SvImpIconView,EditTimeoutHdl));
+
+ Clear( TRUE );
+}
+
+SvImpIconView::~SvImpIconView()
+{
+ StopEditTimer();
+ CancelUserEvent();
+ delete pZOrderList;
+ delete pImpCursor;
+ delete pDDDev;
+ delete pDDBufDev;
+ delete pDDTempDev;
+ ClearSelectedRectList();
+}
+
+void SvImpIconView::Clear( BOOL bInCtor )
+{
+ StopEditTimer();
+ CancelUserEvent();
+ nMaxBmpWidth = 0;
+ nMaxBmpHeight = 0;
+ nMaxTextWidth = 0;
+ bMustRecalcBoundingRects = FALSE;
+ nMaxBoundHeight = 0;
+
+ //XXX
+ nFlags |= F_GRID_INSERT;
+ nFlags &= ~F_PAINTED;
+ SetNextEntryPos( Point( LROFFS_WINBORDER, TBOFFS_WINBORDER ) );
+ pCursor = 0;
+ if( !bInCtor )
+ {
+ pImpCursor->Clear();
+ aVirtOutputSize.Width() = 0;
+ aVirtOutputSize.Height() = 0;
+ pZOrderList->Remove(0,pZOrderList->Count());
+ MapMode aMapMode( pView->GetMapMode());
+ aMapMode.SetOrigin( Point() );
+ pView->SetMapMode( aMapMode );
+ if( pView->IsUpdateMode() )
+ pView->Invalidate();
+ }
+ AdjustScrollBars();
+}
+
+void SvImpIconView::SetWindowBits( WinBits nWinStyle )
+{
+ nWinBits = nWinStyle;
+ nViewMode = VIEWMODE_TEXT;
+ if( nWinStyle & WB_NAME )
+ nViewMode = VIEWMODE_NAME;
+ if( nWinStyle & WB_ICON )
+ nViewMode = VIEWMODE_ICON;
+}
+
+
+IMPL_LINK( SvImpIconView, ScrollUpDownHdl, ScrollBar *, pScrollBar )
+{
+ pView->EndEditing( TRUE );
+ // Pfeil hoch: delta=-1; Pfeil runter: delta=+1
+ Scroll( 0, pScrollBar->GetDelta(), TRUE );
+ return 0;
+}
+
+IMPL_LINK( SvImpIconView, ScrollLeftRightHdl, ScrollBar *, pScrollBar )
+{
+ pView->EndEditing( TRUE );
+ // Pfeil links: delta=-1; Pfeil rechts: delta=+1
+ Scroll( pScrollBar->GetDelta(), 0, TRUE );
+ return 0;
+}
+
+void SvImpIconView::ChangedFont()
+{
+ StopEditTimer();
+ ImpArrange();
+}
+
+
+void SvImpIconView::CheckAllSizes()
+{
+ nMaxTextWidth = 0;
+ nMaxBmpWidth = 0;
+ nMaxBmpHeight = 0;
+ SvLBoxEntry* pEntry = pModel->First();
+ while( pEntry )
+ {
+ CheckSizes( pEntry );
+ pEntry = pModel->Next( pEntry );
+ }
+}
+
+void SvImpIconView::CheckSizes( SvLBoxEntry* pEntry,
+ const SvIcnVwDataEntry* pViewData )
+{
+ Size aSize;
+
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+
+ SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if( pStringItem )
+ {
+ aSize = GetItemSize( pView, pEntry, pStringItem, pViewData );
+ if( aSize.Width() > nMaxTextWidth )
+ {
+ nMaxTextWidth = aSize.Width();
+ if( !(nFlags & F_GRIDMODE ) )
+ bMustRecalcBoundingRects = TRUE;
+ }
+ }
+ SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if( pBmpItem )
+ {
+ aSize = GetItemSize( pView, pEntry, pBmpItem, pViewData );
+ if( aSize.Width() > nMaxBmpWidth )
+ {
+ nMaxBmpWidth = aSize.Width();
+ nMaxBmpWidth += (2*LROFFS_ICON);
+ if( !(nFlags & F_GRIDMODE ) )
+ bMustRecalcBoundingRects = TRUE;
+ }
+ if( aSize.Height() > nMaxBmpHeight )
+ {
+ nMaxBmpHeight = aSize.Height();
+ nMaxBmpHeight += (2*TBOFFS_ICON);;
+ if( !(nFlags & F_GRIDMODE ) )
+ bMustRecalcBoundingRects = TRUE;
+ }
+ }
+}
+
+void SvImpIconView::EntryInserted( SvLBoxEntry* pEntry )
+{
+ if( pModel->GetParent(pEntry) == pCurParent )
+ {
+ StopEditTimer();
+ DBG_ASSERT(pZOrderList->GetPos(pEntry)==0xffff,"EntryInserted:ZOrder?");
+ pZOrderList->Insert( pEntry, pZOrderList->Count() );
+ if( nFlags & F_GRIDMODE )
+ pImpCursor->Clear( FALSE );
+ else
+ pImpCursor->Clear( TRUE );
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ CheckSizes( pEntry, pViewData );
+ if( pView->IsUpdateMode() )
+ {
+ FindBoundingRect( pEntry, pViewData );
+ PaintEntry( pEntry, pViewData );
+ }
+ else
+ InvalidateBoundingRect( pViewData->aRect );
+ }
+}
+
+void SvImpIconView::RemovingEntry( SvLBoxEntry* pEntry )
+{
+ if( pModel->GetParent(pEntry) == pCurParent)
+ {
+ StopEditTimer();
+ DBG_ASSERT(pZOrderList->GetPos(pEntry)!=0xffff,"RemovingEntry:ZOrder?");
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( IsBoundingRectValid( pViewData->aRect ) )
+ {
+ // bei gueltigem Bounding-Rect muss in EntryRemoved eine
+ // Sonderbehandlung erfolgen
+ nFlags |= F_ENTRY_REMOVED;
+ pView->Invalidate( pViewData->aRect );
+ }
+ if( pEntry == pCursor )
+ {
+ SvLBoxEntry* pNewCursor = GetNewCursor();
+ ShowCursor( FALSE );
+ pCursor = 0; // damit er nicht deselektiert wird
+ SetCursor( pNewCursor );
+ }
+ USHORT nPos = pZOrderList->GetPos( (void*)pEntry );
+ pZOrderList->Remove( nPos, 1 );
+ pImpCursor->Clear();
+ }
+}
+
+void SvImpIconView::EntryRemoved()
+{
+ if( (nFlags & (F_ENTRY_REMOVED | F_PAINTED)) == (F_ENTRY_REMOVED | F_PAINTED))
+ {
+ // Ein Eintrag mit gueltigem BoundRect wurde geloescht und wir
+ // haben schon mal gepaintet. In diesem Fall muessen wir die
+ // Position des naechsten Eintrags, der eingefuegt wird oder noch
+ // kein gueltiges BoundRect hat, "suchen" d.h. ein "Loch" in
+ // der View auffuellen.
+ nFlags &= ~( F_ENTRY_REMOVED | F_GRID_INSERT );
+ }
+}
+
+
+void SvImpIconView::MovingEntry( SvLBoxEntry* pEntry )
+{
+ DBG_ASSERT(pEntry,"MovingEntry: 0!");
+ pNextCursor = 0;
+ StopEditTimer();
+ if( pModel->GetParent(pEntry) == pCurParent )
+ {
+ DBG_ASSERT(pZOrderList->GetPos(pEntry)!=0xffff,"MovingEntry:ZOrder?");
+ nFlags |= F_MOVING_SIBLING;
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( IsBoundingRectValid( pViewData->aRect ) )
+ pView->Invalidate( pViewData->aRect );
+ // falls Eintrag seinen Parent wechselt vorsichtshalber
+ // die neue Cursorposition berechnen
+ if( pEntry == pCursor )
+ pNextCursor = GetNewCursor();
+ pImpCursor->Clear();
+ }
+}
+
+
+void SvImpIconView::EntryMoved( SvLBoxEntry* pEntry )
+{
+ ShowCursor( FALSE );
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( pModel->GetParent(pEntry)==pCurParent )
+ {
+ if( nFlags & F_MOVING_SIBLING )
+ {
+ // die Neu-Positionierung eines Eintrags bei D&D innerhalb
+ // einer IconView findet bereits in NotifyMoving statt
+ // (MovingEntry/EntryMoved wird dann nicht mehr gerufen)
+ ToTop( pEntry );
+ }
+ else
+ {
+ pImpCursor->Clear();
+ pZOrderList->Insert( pEntry, pZOrderList->Count() );
+ DBG_ASSERT(pZOrderList->Count()==pModel->GetChildCount(pCurParent),"EntryMoved:Bad zorder count");
+ FindBoundingRect( pEntry, pViewData );
+ }
+ PaintEntry( pEntry, pViewData );
+ }
+ else
+ {
+ if( pEntry == pCursor )
+ {
+ DBG_ASSERT(pNextCursor,"EntryMoved: Next cursor bad");
+ SetCursor( pNextCursor );
+ }
+ pImpCursor->Clear();
+ USHORT nPos = pZOrderList->GetPos( (void*)pEntry );
+ pZOrderList->Remove( nPos, 1 );
+ pView->Select( pEntry, FALSE );
+ // wenn er nochmal in dieser View auftaucht, muss sein
+ // Bounding-Rect neu berechnet werden
+ InvalidateBoundingRect( pViewData->aRect );
+ }
+ nFlags &= (~F_MOVING_SIBLING);
+}
+
+void SvImpIconView::TreeInserted( SvLBoxEntry* pEntry )
+{
+ EntryMoved( pEntry ); // vorlaeufig
+}
+
+void SvImpIconView::EntryExpanded( SvLBoxEntry* )
+{
+}
+
+void SvImpIconView::EntryCollapsed( SvLBoxEntry*)
+{
+}
+
+void SvImpIconView::CollapsingEntry( SvLBoxEntry* )
+{
+}
+
+void SvImpIconView::EntrySelected( SvLBoxEntry* pEntry, BOOL bSelect )
+{
+ if( pModel->GetParent(pEntry) != pCurParent )
+ return;
+
+ // bei SingleSelection dafuer sorgen, dass der Cursor immer
+ // auf dem (einzigen) selektierten Eintrag steht
+ if( bSelect && pCursor &&
+ pView->GetSelectionMode() == SINGLE_SELECTION &&
+ pEntry != pCursor )
+ {
+ SetCursor( pEntry );
+ DBG_ASSERT(pView->GetSelectionCount()==1,"selection count?")
+ }
+ // bei Gummibandselektion ist uns das zu teuer
+ if( !(nFlags & F_RUBBERING ))
+ ToTop( pEntry );
+ if( pView->IsUpdateMode() )
+ {
+ if( pEntry == pCursor )
+ ShowCursor( FALSE );
+ if( nFlags & F_RUBBERING )
+ PaintEntry( pEntry );
+ else
+ pView->Invalidate( GetBoundingRect( pEntry ) );
+ if( pEntry == pCursor )
+ ShowCursor( TRUE );
+ }
+}
+
+void SvImpIconView::SetNextEntryPos(const Point& rPos)
+{
+ aPrevBoundRect.SetPos( rPos );
+ aPrevBoundRect.Right() = LONG_MAX; // dont know
+}
+
+Point SvImpIconView::FindNextEntryPos( const Size& rBoundSize )
+{
+ if( nFlags & F_GRIDMODE )
+ {
+ if( nFlags & F_GRID_INSERT )
+ {
+ if( aPrevBoundRect.Right() != LONG_MAX )
+ {
+ // passt der naechste Entry noch in die Zeile ?
+ long nNextWidth = aPrevBoundRect.Right() + nGridDX + LROFFS_WINBORDER;
+ if( nNextWidth > aVirtOutputSize.Width() )
+ {
+ // darf aVirtOutputSize verbreitert werden ?
+ if( nNextWidth < nMaxVirtWidth )
+ {
+ // verbreitern & in Zeile aufnehmen
+ aPrevBoundRect.Left() += nGridDX;
+ }
+ else
+ {
+ // erhoehen & neue Zeile beginnen
+ aPrevBoundRect.Top() += nGridDY;
+ aPrevBoundRect.Left() = LROFFS_WINBORDER;
+ }
+ }
+ else
+ {
+ // in die Zeile aufnehmen
+ aPrevBoundRect.Left() += nGridDX;
+ }
+ }
+ aPrevBoundRect.SetSize( Size( nGridDX, nGridDY ) );
+ }
+ else
+ {
+ if( !pImpCursor->FindEmptyGridRect( aPrevBoundRect ) )
+ {
+ // mitten in den Entries gibts keine Loecher mehr,
+ // wir koennen also wieder ins "Fast Insert" springen
+ nFlags |= F_GRID_INSERT;
+ }
+ }
+ }
+ else
+ {
+ if( aPrevBoundRect.Right() != LONG_MAX )
+ {
+ // passt der naechste Entry noch in die Zeile ?
+ long nNextWidth=aPrevBoundRect.Right()+rBoundSize.Width()+LROFFS_BOUND+nHorDist;
+ if( nNextWidth > aVirtOutputSize.Width() )
+ {
+ // darf aVirtOutputSize verbreitert werden ?
+ if( nNextWidth < nMaxVirtWidth )
+ {
+ // verbreitern & in Zeile aufnehmen
+ aPrevBoundRect.SetPos( aPrevBoundRect.TopRight() );
+ aPrevBoundRect.Left() += nHorDist;
+ }
+ else
+ {
+ // erhoehen & neue Zeile beginnen
+ aPrevBoundRect.Top() += nMaxBoundHeight + nVerDist + TBOFFS_BOUND;
+ aPrevBoundRect.Left() = LROFFS_WINBORDER;
+ }
+ }
+ else
+ {
+ // in die Zeile aufnehmen
+ aPrevBoundRect.SetPos( aPrevBoundRect.TopRight() );
+ aPrevBoundRect.Left() += nHorDist;
+ }
+ }
+ aPrevBoundRect.SetSize( rBoundSize );
+ }
+ return aPrevBoundRect.TopLeft();
+}
+
+void SvImpIconView::ResetVirtSize()
+{
+ StopEditTimer();
+ aVirtOutputSize.Width() = 0;
+ aVirtOutputSize.Height() = 0;
+ BOOL bLockedEntryFound = FALSE;
+ nFlags &= (~F_GRID_INSERT);
+ SvLBoxEntry* pCur = pModel->FirstChild( pCurParent );
+ while( pCur )
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pCur);
+ if( pViewData->IsEntryPosLocked() )
+ {
+ // VirtSize u.a. anpassen
+ if( !IsBoundingRectValid( pViewData->aRect ) )
+ FindBoundingRect( pCur, pViewData );
+ else
+ AdjustVirtSize( pViewData->aRect );
+ bLockedEntryFound = TRUE;
+ }
+ else
+ InvalidateBoundingRect( pViewData->aRect );
+
+ pCur = pModel->NextSibling( pCur );
+ }
+ if( !bLockedEntryFound )
+ {
+ //XXX
+ nFlags |= F_GRID_INSERT;
+ }
+
+ SetNextEntryPos( Point( LROFFS_WINBORDER, TBOFFS_WINBORDER ) );
+ pImpCursor->Clear();
+}
+
+
+void SvImpIconView::AdjustVirtSize( const Rectangle& rRect )
+{
+ long nHeightOffs = 0;
+ long nWidthOffs = 0;
+
+ if( aVirtOutputSize.Width() < (rRect.Right()+LROFFS_WINBORDER) )
+ nWidthOffs = (rRect.Right()+LROFFS_WINBORDER) - aVirtOutputSize.Width();
+
+ if( aVirtOutputSize.Height() < (rRect.Bottom()+TBOFFS_WINBORDER) )
+ nHeightOffs = (rRect.Bottom()+TBOFFS_WINBORDER) - aVirtOutputSize.Height();
+
+ if( nWidthOffs || nHeightOffs )
+ {
+ Range aRange;
+ aVirtOutputSize.Width() += nWidthOffs;
+ aRange.Max() = aVirtOutputSize.Width();
+ aHorSBar.SetRange( aRange );
+
+ aVirtOutputSize.Height() += nHeightOffs;
+ aRange.Max() = aVirtOutputSize.Height();
+ aVerSBar.SetRange( aRange );
+
+ pImpCursor->Clear();
+ AdjustScrollBars();
+ }
+}
+
+void SvImpIconView::Arrange()
+{
+ nMaxVirtWidth = aOutputSize.Width();
+ ImpArrange();
+}
+
+void SvImpIconView::ImpArrange()
+{
+ StopEditTimer();
+ ShowCursor( FALSE );
+ ResetVirtSize();
+ bMustRecalcBoundingRects = FALSE;
+ MapMode aMapMode( pView->GetMapMode());
+ aMapMode.SetOrigin( Point() );
+ pView->SetMapMode( aMapMode );
+ CheckAllSizes();
+ RecalcAllBoundingRectsSmart();
+ pView->Invalidate();
+ ShowCursor( TRUE );
+}
+
+void SvImpIconView::Paint( const Rectangle& rRect )
+{
+ if( !pView->IsUpdateMode() )
+ return;
+
+#if defined(DBG_UTIL) && defined(OV_DRAWGRID)
+ if( nFlags & F_GRIDMODE )
+ {
+ Color aOldColor = pView->GetLineColor();
+ Color aNewColor( COL_BLACK );
+ pView->SetLineColor( aNewColor );
+ Point aOffs( pView->GetMapMode().GetOrigin());
+ Size aXSize( pView->GetOutputSizePixel() );
+ for( long nDX = nGridDX; nDX <= aXSize.Width(); nDX += nGridDX )
+ {
+ Point aStart( nDX+LROFFS_BOUND, 0 );
+ Point aEnd( nDX+LROFFS_BOUND, aXSize.Height());
+ aStart -= aOffs;
+ aEnd -= aOffs;
+ pView->DrawLine( aStart, aEnd );
+ }
+ for( long nDY = nGridDY; nDY <= aXSize.Height(); nDY += nGridDY )
+ {
+ Point aStart( 0, nDY+TBOFFS_BOUND );
+ Point aEnd( aXSize.Width(), nDY+TBOFFS_BOUND );
+ aStart -= aOffs;
+ aEnd -= aOffs;
+ pView->DrawLine( aStart, aEnd );
+ }
+ pView->SetLineColor( aOldColor );
+ }
+#endif
+ nFlags |= F_PAINTED;
+
+ if( !(pModel->HasChilds( pCurParent ) ))
+ return;
+ if( !pCursor )
+ pCursor = pModel->FirstChild( pCurParent );
+
+ USHORT nCount = pZOrderList->Count();
+ if( !nCount )
+ return;
+
+ SvPtrarr* pNewZOrderList = new SvPtrarr;
+ SvPtrarr* pPaintedEntries = new SvPtrarr;
+
+ USHORT nPos = 0;
+ while( nCount )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nPos ));
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ const Rectangle& rBoundRect = GetBoundingRect( pEntry, pViewData );
+ if( rRect.IsOver( rBoundRect ) )
+ {
+ PaintEntry( pEntry, rBoundRect.TopLeft(), pViewData );
+ // Eintraege, die neu gezeichnet werden, auf Top setzen
+ pPaintedEntries->Insert( pEntry, pPaintedEntries->Count() );
+ }
+ else
+ pNewZOrderList->Insert( pEntry, pNewZOrderList->Count() );
+
+ nCount--;
+ nPos++;
+ }
+ delete pZOrderList;
+ pZOrderList = pNewZOrderList;
+ nCount = pPaintedEntries->Count();
+ if( nCount )
+ {
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ pZOrderList->Insert( pPaintedEntries->GetObject( nCur ),pZOrderList->Count());
+ }
+ delete pPaintedEntries;
+
+ Rectangle aRect;
+ if( GetResizeRect( aRect ))
+ PaintResizeRect( aRect );
+}
+
+BOOL SvImpIconView::GetResizeRect( Rectangle& rRect )
+{
+ if( aHorSBar.IsVisible() && aVerSBar.IsVisible() )
+ {
+ const MapMode& rMapMode = pView->GetMapMode();
+ Point aOrigin( rMapMode.GetOrigin());
+ aOrigin *= -1;
+ aOrigin.X() += aOutputSize.Width();
+ aOrigin.Y() += aOutputSize.Height();
+ rRect.SetPos( aOrigin );
+ rRect.SetSize( Size( nVerSBarWidth, nHorSBarHeight));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void SvImpIconView::PaintResizeRect( const Rectangle& rRect )
+{
+ const StyleSettings& rStyleSettings = pView->GetSettings().GetStyleSettings();
+ Color aNewColor = rStyleSettings.GetFaceColor();
+ Color aOldColor = pView->GetFillColor();
+ pView->SetFillColor( aNewColor );
+ pView->DrawRect( rRect );
+ pView->SetFillColor( aOldColor );
+}
+
+void SvImpIconView::RepaintSelectionItems()
+{
+ DBG_ERROR("RepaintSelectionItems");
+ pView->Invalidate(); // vorlaeufig
+}
+
+SvLBoxItem* SvImpIconView::GetItem( SvLBoxEntry* pEntry,
+ const Point& rAbsPos )
+{
+ Rectangle aRect;
+ SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if( pStringItem )
+ {
+ aRect = CalcTextRect( pEntry, pStringItem );
+ if( aRect.IsInside( rAbsPos ) )
+ return pStringItem;
+ }
+ SvLBoxContextBmp* pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ if( pBmpItem )
+ {
+ aRect = CalcBmpRect( pEntry );
+ if( aRect.IsInside( rAbsPos ) )
+ return pBmpItem;
+ }
+ return 0;
+}
+
+void SvImpIconView::CalcDocPos( Point& aMaeuschenPos )
+{
+ aMaeuschenPos -= pView->GetMapMode().GetOrigin();
+}
+
+void SvImpIconView::MouseButtonDown( const MouseEvent& rMEvt)
+{
+ StopEditTimer();
+ pView->GrabFocus();
+ Point aDocPos( rMEvt.GetPosPixel() );
+ if(aDocPos.X()>=aOutputSize.Width() || aDocPos.Y()>=aOutputSize.Height())
+ return;
+ CalcDocPos( aDocPos );
+ SvLBoxEntry* pEntry = GetEntry( aDocPos );
+ if( !pEntry )
+ {
+ if( pView->GetSelectionMode() != SINGLE_SELECTION )
+ {
+ if( !rMEvt.IsMod1() ) // Ctrl
+ {
+ pView->SelectAll( FALSE );
+ ClearSelectedRectList();
+ }
+ else
+ nFlags |= F_ADD_MODE;
+ nFlags |= F_RUBBERING;
+ aCurSelectionRect.SetPos( aDocPos );
+ pView->CaptureMouse();
+ }
+ return;
+ }
+
+ BOOL bSelected = pView->IsSelected( pEntry );
+ BOOL bEditingEnabled = pView->IsInplaceEditingEnabled();
+
+ if( rMEvt.GetClicks() == 2 )
+ {
+ DeselectAllBut( pEntry );
+ pView->pHdlEntry = pEntry;
+ pView->DoubleClickHdl();
+ }
+ else
+ {
+ // Inplace-Editing ?
+ if( rMEvt.IsMod2() ) // Alt?
+ {
+ if( bEditingEnabled )
+ {
+ SvLBoxItem* pItem = GetItem(pEntry,aDocPos);
+ if( pItem )
+ pView->EditingRequest( pEntry, pItem, aDocPos);
+ }
+ }
+ else if( pView->GetSelectionMode() == SINGLE_SELECTION )
+ {
+ DeselectAllBut( pEntry );
+ SetCursor( pEntry );
+ pView->Select( pEntry, TRUE );
+ if( bEditingEnabled && bSelected && !rMEvt.GetModifier() &&
+ rMEvt.IsLeft() && IsTextHit( pEntry, aDocPos ) )
+ {
+ nFlags |= F_START_EDITTIMER_IN_MOUSEUP;
+ }
+ }
+ else
+ {
+ if( !rMEvt.GetModifier() )
+ {
+ if( !bSelected )
+ {
+ DeselectAllBut( pEntry );
+ SetCursor( pEntry );
+ pView->Select( pEntry, TRUE );
+ }
+ else
+ {
+ // erst im Up deselektieren, falls Move per D&D!
+ nFlags |= F_DOWN_DESELECT;
+ if( bEditingEnabled && IsTextHit( pEntry, aDocPos ) &&
+ rMEvt.IsLeft())
+ {
+ nFlags |= F_START_EDITTIMER_IN_MOUSEUP;
+ }
+ }
+ }
+ else if( rMEvt.IsMod1() )
+ nFlags |= F_DOWN_CTRL;
+ }
+ }
+}
+
+void SvImpIconView::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ aMouseMoveTimer.Stop();
+ pView->ReleaseMouse();
+ // HACK, da Einar noch nicht PrepareCommandEvent aufruft
+ if( rMEvt.IsRight() && (nFlags & (F_DOWN_CTRL | F_DOWN_DESELECT) ))
+ nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
+
+ if( nFlags & F_RUBBERING )
+ {
+ aMouseMoveTimer.Stop();
+ AddSelectedRect( aCurSelectionRect );
+ HideSelectionRect();
+ nFlags &= ~(F_RUBBERING | F_ADD_MODE);
+ }
+
+ SvLBoxEntry* pEntry = pView->GetEntry( rMEvt.GetPosPixel(), TRUE );
+ if( pEntry )
+ {
+ if( nFlags & F_DOWN_CTRL )
+ {
+ // Ctrl & MultiSelection
+ ToggleSelection( pEntry );
+ SetCursor( pEntry );
+ }
+ else if( nFlags & F_DOWN_DESELECT )
+ {
+ DeselectAllBut( pEntry );
+ SetCursor( pEntry );
+ pView->Select( pEntry, TRUE );
+ }
+ }
+
+ nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
+ if( nFlags & F_START_EDITTIMER_IN_MOUSEUP )
+ {
+ StartEditTimer();
+ nFlags &= ~F_START_EDITTIMER_IN_MOUSEUP;
+ }
+}
+
+void SvImpIconView::MouseMove( const MouseEvent& rMEvt )
+{
+ if( nFlags & F_RUBBERING )
+ {
+ const Point& rPosPixel = rMEvt.GetPosPixel();
+ if( !aMouseMoveTimer.IsActive() )
+ {
+ aMouseMoveEvent = rMEvt;
+ aMouseMoveTimer.Start();
+ // ausserhalb des Fensters liegende Move-Events muessen
+ // vom Timer kommen, damit die Scrollgeschwindigkeit
+ // unabhaengig von Mausbewegungen ist.
+ if( rPosPixel.X() < 0 || rPosPixel.Y() < 0 )
+ return;
+ const Size& rSize = pView->GetOutputSizePixel();
+ if( rPosPixel.X() > rSize.Width() || rPosPixel.Y() > rSize.Height())
+ return;
+ }
+
+ if( &rMEvt != &aMouseMoveEvent )
+ aMouseMoveEvent = rMEvt;
+
+ long nScrollDX, nScrollDY;
+
+ CalcScrollOffsets(rMEvt.GetPosPixel(),nScrollDX,nScrollDY,FALSE );
+ BOOL bSelRectHidden = FALSE;
+ if( nScrollDX || nScrollDY )
+ {
+ HideSelectionRect();
+ bSelRectHidden = TRUE;
+ pView->Scroll( nScrollDX, nScrollDY );
+ }
+ Point aDocPos( rMEvt.GetPosPixel() );
+ aDocPos = pView->PixelToLogic( aDocPos );
+ Rectangle aRect( aCurSelectionRect.TopLeft(), aDocPos );
+ if( aRect != aCurSelectionRect )
+ {
+ HideSelectionRect();
+ bSelRectHidden = TRUE;
+ BOOL bAdd = (nFlags & F_ADD_MODE) ? TRUE : FALSE;
+ SelectRect( aRect, bAdd, &aSelectedRectList );
+ }
+ if( bSelRectHidden )
+ DrawSelectionRect( aRect );
+ }
+}
+
+BOOL SvImpIconView::KeyInput( const KeyEvent& rKEvt )
+{
+ StopEditTimer();
+ BOOL bKeyUsed = TRUE;
+ BOOL bMod1 = rKEvt.GetKeyCode().IsMod1();
+ BOOL bInAddMode = (BOOL)((nFlags & F_ADD_MODE) != 0);
+ int bDeselAll = (pView->GetSelectionMode() != SINGLE_SELECTION) &&
+ !bInAddMode;
+ SvLBoxEntry* pNewCursor;
+ USHORT nCode = rKEvt.GetKeyCode().GetCode();
+ switch( nCode )
+ {
+ case KEY_UP:
+ if( pCursor )
+ {
+ MakeVisible( pCursor );
+ pNewCursor = pImpCursor->GoUpDown(pCursor,FALSE);
+ if( pNewCursor )
+ {
+ if( bDeselAll )
+ pView->SelectAll( FALSE );
+ ShowCursor( FALSE );
+ MakeVisible( pNewCursor );
+ SetCursor( pNewCursor );
+ if( !bInAddMode )
+ pView->Select( pCursor, TRUE );
+ }
+ else
+ {
+ Rectangle aRect( GetBoundingRect( pCursor ) );
+ if( aRect.Top())
+ {
+ aRect.Bottom() -= aRect.Top();
+ aRect.Top() = 0;
+ MakeVisible( aRect );
+ }
+ }
+ }
+ break;
+
+ case KEY_DOWN:
+ if( pCursor )
+ {
+ pNewCursor=pImpCursor->GoUpDown( pCursor,TRUE );
+ if( pNewCursor )
+ {
+ MakeVisible( pCursor );
+ if( bDeselAll )
+ pView->SelectAll( FALSE );
+ ShowCursor( FALSE );
+ MakeVisible( pNewCursor );
+ SetCursor( pNewCursor );
+ if( !bInAddMode )
+ pView->Select( pCursor, TRUE );
+ }
+ }
+ break;
+
+ case KEY_RIGHT:
+ if( pCursor )
+ {
+ pNewCursor=pImpCursor->GoLeftRight(pCursor,TRUE );
+ if( pNewCursor )
+ {
+ MakeVisible( pCursor );
+ if( bDeselAll )
+ pView->SelectAll( FALSE );
+ ShowCursor( FALSE );
+ MakeVisible( pNewCursor );
+ SetCursor( pNewCursor );
+ if( !bInAddMode )
+ pView->Select( pCursor, TRUE );
+ }
+ }
+ break;
+
+ case KEY_LEFT:
+ if( pCursor )
+ {
+ MakeVisible( pCursor );
+ pNewCursor = pImpCursor->GoLeftRight(pCursor,FALSE );
+ if( pNewCursor )
+ {
+ if( bDeselAll )
+ pView->SelectAll( FALSE );
+ ShowCursor( FALSE );
+ MakeVisible( pNewCursor );
+ SetCursor( pNewCursor );
+ if( !bInAddMode )
+ pView->Select( pCursor, TRUE );
+ }
+ else
+ {
+ Rectangle aRect( GetBoundingRect(pCursor));
+ if( aRect.Left() )
+ {
+ aRect.Right() -= aRect.Left();
+ aRect.Left() = 0;
+ MakeVisible( aRect );
+ }
+ }
+ }
+ break;
+
+ case KEY_ESCAPE:
+ if( nFlags & F_RUBBERING )
+ {
+ HideSelectionRect();
+ pView->SelectAll( FALSE );
+ nFlags &= ~F_RUBBERING;
+ }
+ break;
+
+ case KEY_F8:
+ if( rKEvt.GetKeyCode().IsShift() )
+ {
+ if( nFlags & F_ADD_MODE )
+ nFlags &= (~F_ADD_MODE);
+ else
+ nFlags |= F_ADD_MODE;
+ }
+ break;
+
+#ifdef OS2
+ case KEY_F9:
+ if( rKEvt.GetKeyCode().IsShift() )
+ {
+ if( pCursor && pView->IsInplaceEditingEnabled() )
+ pView->EditEntry( pCursor );
+ }
+ break;
+#endif
+
+ case KEY_SPACE:
+ if( pCursor )
+ {
+ ToggleSelection( pCursor );
+ }
+ break;
+
+
+ case KEY_PAGEDOWN:
+ break;
+ case KEY_PAGEUP:
+ break;
+
+ case KEY_ADD:
+ case KEY_DIVIDE :
+ if( bMod1 )
+ pView->SelectAll( TRUE );
+ break;
+
+ case KEY_SUBTRACT:
+ case KEY_COMMA :
+ if( bMod1 )
+ pView->SelectAll( FALSE );
+ break;
+
+ case KEY_RETURN:
+ if( bMod1 )
+ {
+ if( pCursor && pView->IsInplaceEditingEnabled() )
+ pView->EditEntry( pCursor );
+ }
+ break;
+
+ default:
+ bKeyUsed = FALSE;
+
+ }
+ return bKeyUsed;
+}
+
+
+void SvImpIconView::PositionScrollBars( long nRealWidth, long nRealHeight )
+{
+ // hor scrollbar
+ Point aPos( 0, nRealHeight );
+ aPos.Y() -= nHorSBarHeight;
+
+#ifdef WIN
+ // vom linken und unteren Rand ein Pixel abschneiden
+ aPos.Y()++;
+ aPos.X()--;
+#endif
+#ifdef OS2
+ aPos.Y()++;
+#endif
+ if( aHorSBar.GetPosPixel() != aPos )
+ aHorSBar.SetPosPixel( aPos );
+
+ // ver scrollbar
+ aPos.X() = nRealWidth; aPos.Y() = 0;
+ aPos.X() -= nVerSBarWidth;
+
+#if defined(WIN) || defined(WNT)
+ aPos.X()++;
+ aPos.Y()--;
+#endif
+
+#ifdef OS2
+ aPos.Y()--;
+ aPos.X()++;
+#endif
+
+#ifdef MAC
+ aPos.Y()--;
+ aPos.X()++;
+#endif
+ if( aVerSBar.GetPosPixel() != aPos )
+ aVerSBar.SetPosPixel( aPos );
+}
+
+
+
+void SvImpIconView::AdjustScrollBars( BOOL bVirtSizeGrowedOnly )
+{
+ long nVirtHeight = aVirtOutputSize.Height();
+ long nVirtWidth = aVirtOutputSize.Width();
+
+ Size aOSize( pView->Control::GetOutputSizePixel() );
+ long nRealHeight = aOSize.Height();
+ long nRealWidth = aOSize.Width();
+
+ PositionScrollBars( nRealWidth, nRealHeight );
+
+ const MapMode& rMapMode = pView->GetMapMode();
+ Point aOrigin( rMapMode.GetOrigin() );
+
+ long nVisibleWidth;
+ if( nRealWidth > nVirtWidth )
+ nVisibleWidth = nVirtWidth + aOrigin.X();
+ else
+ nVisibleWidth = nRealWidth;
+
+ long nVisibleHeight;
+ if( nRealHeight > nVirtHeight )
+ nVisibleHeight = nVirtHeight + aOrigin.Y();
+ else
+ nVisibleHeight = nRealHeight;
+
+ int bVerSBar = pView->nWindowStyle & WB_VSCROLL;
+ int bHorSBar = pView->nWindowStyle & WB_HSCROLL;
+
+ USHORT nResult = 0;
+ if( nVirtHeight )
+ {
+ // activate ver scrollbar ?
+ if( bVerSBar || ( nVirtHeight > nVisibleHeight) )
+ {
+ nResult = 0x0001;
+ nRealWidth -= nVerSBarWidth;
+
+ if( nRealWidth > nVirtWidth )
+ nVisibleWidth = nVirtWidth + aOrigin.X();
+ else
+ nVisibleWidth = nRealWidth;
+
+ nFlags |= F_HOR_SBARSIZE_WITH_VBAR;
+ }
+ // activate hor scrollbar ?
+ if( bHorSBar || (nVirtWidth > nVisibleWidth) )
+ {
+ nResult |= 0x0002;
+ nRealHeight -= nHorSBarHeight;
+
+ if( nRealHeight > nVirtHeight )
+ nVisibleHeight = nVirtHeight + aOrigin.Y();
+ else
+ nVisibleHeight = nRealHeight;
+
+ // brauchen wir jetzt doch eine senkrechte Scrollbar ?
+ if( !(nResult & 0x0001) && // nur wenn nicht schon da
+ ( (nVirtHeight > nVisibleHeight) || bVerSBar) )
+ {
+ nResult = 3; // both are active
+ nRealWidth -= nVerSBarWidth;
+
+ if( nRealWidth > nVirtWidth )
+ nVisibleWidth = nVirtWidth + aOrigin.X();
+ else
+ nVisibleWidth = nRealWidth;
+
+ nFlags |= F_VER_SBARSIZE_WITH_HBAR;
+ }
+ }
+ }
+
+ // size ver scrollbar
+ long nThumb = aVerSBar.GetThumbPos();
+ Size aSize( nVerSBarWidth, nRealHeight );
+#if defined(WIN) || defined(WNT)
+ aSize.Height() += 2;
+#endif
+#ifdef OS2
+ aSize.Height() += 3;
+#endif
+#ifdef MAC
+ aSize.Height() += 2;
+#endif
+ if( aSize != aVerSBar.GetSizePixel() )
+ aVerSBar.SetSizePixel( aSize );
+ aVerSBar.SetVisibleSize( nVisibleHeight );
+ aVerSBar.SetPageSize( (nVisibleHeight*75)/100 );
+ if( nResult & 0x0001 )
+ {
+ aVerSBar.SetThumbPos( nThumb );
+ aVerSBar.Show();
+ }
+ else
+ {
+ aVerSBar.SetThumbPos( 0 );
+ aVerSBar.Hide();
+ }
+
+ // size hor scrollbar
+ nThumb = aHorSBar.GetThumbPos();
+ aSize.Width() = nRealWidth;
+ aSize.Height() = nHorSBarHeight;
+#if defined(WIN) || defined(WNT)
+ aSize.Width()++;
+#endif
+#ifdef OS2
+ aSize.Width() += 3;
+ if( nResult & 0x0001 ) // vertikale Scrollbar ?
+ aSize.Width()--;
+#endif
+#if defined(WIN) || defined(WNT)
+ if( nResult & 0x0001 ) // vertikale Scrollbar ?
+ {
+ aSize.Width()++;
+ nRealWidth++;
+ }
+#endif
+ if( aSize != aHorSBar.GetSizePixel() )
+ aHorSBar.SetSizePixel( aSize );
+ aHorSBar.SetVisibleSize( nVisibleWidth ); //nRealWidth );
+ aHorSBar.SetPageSize( (nVisibleWidth*75)/100 );
+ if( nResult & 0x0002 )
+ {
+ aHorSBar.SetThumbPos( nThumb );
+ aHorSBar.Show();
+ }
+ else
+ {
+ aHorSBar.SetThumbPos( 0 );
+ aHorSBar.Hide();
+ }
+
+#ifdef OS2
+ nRealWidth++;
+#endif
+ aOutputSize.Width() = nRealWidth;
+#if defined(WIN) || defined(WNT)
+ if( nResult & 0x0002 ) // hor scrollbar ?
+ nRealHeight++; // weil unterer Rand geclippt wird
+#endif
+#ifdef OS2
+ if( nResult & 0x0002 ) // hor scrollbar ?
+ nRealHeight++;
+#endif
+ aOutputSize.Height() = nRealHeight;
+}
+
+void __EXPORT SvImpIconView::Resize()
+{
+ StopEditTimer();
+ Rectangle aRect;
+ if( GetResizeRect(aRect) )
+ pView->Invalidate( aRect );
+ aOutputSize = pView->GetOutputSizePixel();
+ pImpCursor->Clear();
+
+#if 1
+ const Size& rSize = pView->Control::GetOutputSizePixel();
+ PositionScrollBars( rSize.Width(), rSize.Height() );
+ // Die ScrollBars werden asynchron ein/ausgeblendet, damit abgeleitete
+ // Klassen im Resize ein Arrange durchfuehren koennen, ohne dass
+ // die ScrollBars aufblitzen (SfxExplorerIconView!)
+ nCurUserEvent = Application::PostUserEvent(LINK(this,SvImpIconView,UserEventHdl),0);
+#else
+ AdjustScrollBars();
+ if( GetResizeRect(aRect) )
+ PaintResizeRect( aRect );
+#endif
+}
+
+BOOL SvImpIconView::CheckHorScrollBar()
+{
+ if( !pZOrderList || !aHorSBar.IsVisible() )
+ return FALSE;
+ const MapMode& rMapMode = pView->GetMapMode();
+ Point aOrigin( rMapMode.GetOrigin() );
+ if(!(pView->nWindowStyle & WB_HSCROLL) && !aOrigin.X() )
+ {
+ long nWidth = aOutputSize.Width();
+ USHORT nCount = pZOrderList->Count();
+ long nMostRight = 0;
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pZOrderList->operator[](nCur);
+ long nRight = GetBoundingRect(pEntry).Right();
+ if( nRight > nWidth )
+ return FALSE;
+ if( nRight > nMostRight )
+ nMostRight = nRight;
+ }
+ aHorSBar.Hide();
+ aOutputSize.Height() += nHorSBarHeight;
+ aVirtOutputSize.Width() = nMostRight;
+ aHorSBar.SetThumbPos( 0 );
+ Range aRange;
+ aRange.Max() = nMostRight - 1;
+ aHorSBar.SetRange( aRange );
+ if( aVerSBar.IsVisible() )
+ {
+ Size aSize( aVerSBar.GetSizePixel());
+ aSize.Height() += nHorSBarHeight;
+ aVerSBar.SetSizePixel( aSize );
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL SvImpIconView::CheckVerScrollBar()
+{
+ if( !pZOrderList || !aVerSBar.IsVisible() )
+ return FALSE;
+ const MapMode& rMapMode = pView->GetMapMode();
+ Point aOrigin( rMapMode.GetOrigin() );
+ if(!(pView->nWindowStyle & WB_VSCROLL) && !aOrigin.Y() )
+ {
+ long nDeepest = 0;
+ long nHeight = aOutputSize.Height();
+ USHORT nCount = pZOrderList->Count();
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pZOrderList->operator[](nCur);
+ long nBottom = GetBoundingRect(pEntry).Bottom();
+ if( nBottom > nHeight )
+ return FALSE;
+ if( nBottom > nDeepest )
+ nDeepest = nBottom;
+ }
+ aVerSBar.Hide();
+ aOutputSize.Width() += nVerSBarWidth;
+ aVirtOutputSize.Height() = nDeepest;
+ aVerSBar.SetThumbPos( 0 );
+ Range aRange;
+ aRange.Max() = nDeepest - 1;
+ aVerSBar.SetRange( aRange );
+ if( aHorSBar.IsVisible() )
+ {
+ Size aSize( aHorSBar.GetSizePixel());
+ aSize.Width() += nVerSBarWidth;
+ aHorSBar.SetSizePixel( aSize );
+ }
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+// blendet Scrollbars aus, wenn sie nicht mehr benoetigt werden
+void SvImpIconView::CheckScrollBars()
+{
+ CheckVerScrollBar();
+ if( CheckHorScrollBar() )
+ CheckVerScrollBar();
+}
+
+
+void __EXPORT SvImpIconView::GetFocus()
+{
+ if( pCursor )
+ {
+ pView->SetEntryFocus( pCursor, TRUE );
+ ShowCursor( TRUE );
+ }
+}
+
+void __EXPORT SvImpIconView::LoseFocus()
+{
+ StopEditTimer();
+ if( pCursor )
+ pView->SetEntryFocus( pCursor,FALSE );
+ ShowCursor( FALSE );
+}
+
+void SvImpIconView::UpdateAll()
+{
+ AdjustScrollBars();
+ pImpCursor->Clear();
+ pView->Invalidate();
+}
+
+void SvImpIconView::PaintEntry( SvLBoxEntry* pEntry, SvIcnVwDataEntry* pViewData )
+{
+ Point aPos( GetEntryPos( pEntry ) );
+ PaintEntry( pEntry, aPos, pViewData );
+}
+
+void SvImpIconView::PaintEmphasis( const Rectangle& rRect, BOOL bSelected,
+ BOOL bInUse, BOOL bCursored,
+ OutputDevice* pOut )
+{
+ // HACK fuer D&D
+ if( nFlags & F_NO_EMPHASIS )
+ return;
+
+ if( !pOut )
+ pOut = pView;
+
+ // Selektion painten
+ Color aOldFillColor = pOut->GetFillColor();
+ Color aOldLineColor = pOut->GetLineColor();
+ Color aNewColor;
+ const StyleSettings& rStyleSettings = pOut->GetSettings().GetStyleSettings();
+ if( bSelected )
+ {
+ aNewColor = rStyleSettings.GetHighlightColor();
+ }
+ else
+ {
+#ifndef OS2
+ aNewColor =rStyleSettings.GetFieldColor();
+#else
+ aNewColor = pOut->GetBackground().GetColor();
+#endif
+ }
+
+ if( bCursored )
+ {
+ pOut->SetLineColor( Color( COL_BLACK ) );
+ }
+ pOut->SetFillColor( aNewColor );
+ pOut->DrawRect( rRect );
+ pOut->SetFillColor( aOldFillColor );
+ pOut->SetLineColor( aOldLineColor );
+}
+
+void SvImpIconView::PaintItem( const Rectangle& rRect,
+ SvLBoxItem* pItem, SvLBoxEntry* pEntry, USHORT nPaintFlags,
+ OutputDevice* pOut )
+{
+ if( nViewMode == VIEWMODE_ICON && pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
+ {
+ const String& rStr = ((SvLBoxString*)pItem)->GetText();
+ DrawText( pOut, rRect, rStr, DRAWTEXT_FLAGS );
+ }
+ else
+ {
+ Point aPos( rRect.TopLeft() );
+ const Size& rSize = GetItemSize( pView, pEntry, pItem );
+ if( nPaintFlags & PAINTFLAG_HOR_CENTERED )
+ aPos.X() += (rRect.GetWidth() - rSize.Width() ) / 2;
+ if( nPaintFlags & PAINTFLAG_VER_CENTERED )
+ aPos.Y() += (rRect.GetHeight() - rSize.Height() ) / 2;
+ pItem->Paint( aPos, *(SvLBox*)pOut, 0, pEntry );
+ }
+}
+
+void SvImpIconView::PaintEntry( SvLBoxEntry* pEntry, const Point& rPos,
+ SvIcnVwDataEntry* pViewData, OutputDevice* pOut )
+{
+ if( !pView->IsUpdateMode() )
+ return;
+
+ if( !pOut )
+ pOut = pView;
+
+ SvLBoxContextBmp* pBmpItem;
+
+ pView->PreparePaint( pEntry );
+
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+
+ SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+
+ BOOL bSelected = pViewData->IsSelected();
+ BOOL bCursored = pViewData->IsCursored();
+ BOOL bInUse = pEntry->HasInUseEmphasis();
+
+ Font aTempFont( pOut->GetFont() );
+ // waehrend D&D nicht die Fontfarbe wechseln, da sonst auch die
+ // Emphasis gezeichnet werden muss! (weisser Adler auf weissem Grund)
+ if( bSelected && !(nFlags & F_NO_EMPHASIS) )
+ {
+ const StyleSettings& rStyleSettings = pOut->GetSettings().GetStyleSettings();
+ Font aNewFont( aTempFont );
+ aNewFont.SetColor( rStyleSettings.GetHighlightTextColor() );
+ pOut->SetFont( aNewFont );
+ }
+ Rectangle aTextRect( CalcTextRect(pEntry,pStringItem,&rPos,FALSE,pViewData));
+ Rectangle aBmpRect( CalcBmpRect(pEntry, &rPos, pViewData ) );
+
+ switch( nViewMode )
+ {
+ case VIEWMODE_ICON:
+ pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ PaintEmphasis( aBmpRect, bSelected, bInUse, bCursored, pOut );
+ PaintItem( aBmpRect, pBmpItem, pEntry,
+ PAINTFLAG_HOR_CENTERED | PAINTFLAG_VER_CENTERED, pOut );
+ PaintEmphasis( aTextRect, bSelected, FALSE, FALSE, pOut );
+ PaintItem( aTextRect, pStringItem, pEntry, PAINTFLAG_HOR_CENTERED, pOut );
+ break;
+
+ case VIEWMODE_NAME:
+ pBmpItem = (SvLBoxContextBmp*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP));
+ PaintEmphasis( aBmpRect, bSelected, bInUse, bCursored, pOut );
+ PaintItem( aBmpRect, pBmpItem, pEntry, PAINTFLAG_VER_CENTERED, pOut );
+ PaintEmphasis( aTextRect, bSelected, FALSE, FALSE, pOut );
+ PaintItem( aTextRect, pStringItem, pEntry,PAINTFLAG_VER_CENTERED, pOut );
+ break;
+
+ case VIEWMODE_TEXT:
+ PaintEmphasis( aTextRect, bSelected, FALSE, bCursored, pOut );
+ PaintItem( aTextRect, pStringItem, pEntry, PAINTFLAG_VER_CENTERED, pOut );
+ break;
+ }
+ pOut->SetFont( aTempFont );
+}
+
+void SvImpIconView::SetEntryPos( SvLBoxEntry* pEntry, const Point& rPos,
+ BOOL bAdjustAtGrid, BOOL bCheckScrollBars )
+{
+ if( pModel->GetParent(pEntry) == pCurParent )
+ {
+ ShowCursor( FALSE );
+ long nVirtHeightOffs = 0;
+ long nVirtWidthOffs = 0;
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ Rectangle aBoundRect( GetBoundingRect( pEntry, pViewData ));
+ pView->Invalidate( aBoundRect );
+ ToTop( pEntry );
+ if( rPos != aBoundRect.TopLeft() )
+ {
+ Point aGridOffs = pViewData->aGridRect.TopLeft() -
+ pViewData->aRect.TopLeft();
+ pImpCursor->Clear();
+ nFlags &= ~F_GRID_INSERT;
+ aBoundRect.SetPos( rPos );
+ pViewData->aRect = aBoundRect;
+ pViewData->aGridRect.SetPos( rPos + aGridOffs );
+ AdjustVirtSize( aBoundRect );
+ }
+ //HACK(Billigloesung, die noch verbessert werden muss)
+ if( bAdjustAtGrid )
+ {
+ AdjustAtGrid( pEntry );
+ ToTop( pEntry );
+ }
+ if( bCheckScrollBars && pView->IsUpdateMode() )
+ CheckScrollBars();
+
+ PaintEntry( pEntry, pViewData );
+ ShowCursor( TRUE );
+ }
+}
+
+void SvImpIconView::ViewDataInitialized( SvLBoxEntry*)
+{
+}
+
+void SvImpIconView::ModelHasEntryInvalidated( SvListEntry* pEntry )
+{
+ if( pEntry == pCursor )
+ ShowCursor( FALSE );
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ pView->Invalidate( pViewData->aRect );
+
+ if( nFlags & F_GRIDMODE )
+ Center( (SvLBoxEntry*)pEntry, pViewData );
+ else
+ pViewData->aRect.SetSize( CalcBoundingSize(
+ (SvLBoxEntry*)pEntry, pViewData ) );
+
+ ViewDataInitialized( (SvLBoxEntry*)pEntry );
+ pView->Invalidate( pViewData->aRect );
+ if( pEntry == pCursor )
+ ShowCursor( TRUE );
+}
+
+
+void SvImpIconView::InvalidateEntry( SvLBoxEntry* pEntry )
+{
+ const Rectangle& rRect = GetBoundingRect( pEntry );
+ pView->Invalidate( rRect );
+}
+
+void SvImpIconView::SetNoSelection()
+{
+}
+
+void SvImpIconView::SetDragDropMode( DragDropMode )
+{
+}
+
+void SvImpIconView::SetSelectionMode( SelectionMode )
+{
+}
+
+BOOL SvImpIconView::IsEntryInView( SvLBoxEntry* )
+{
+ return FALSE;
+}
+
+SvLBoxEntry* SvImpIconView::GetDropTarget( const Point& rPos )
+{
+ Point aDocPos( rPos );
+ CalcDocPos( aDocPos );
+ SvLBoxEntry* pTarget = GetEntry( aDocPos );
+ if( !pTarget || !pTarget->HasChilds() )
+ pTarget = pCurParent;
+ return pTarget;
+}
+
+SvLBoxEntry* SvImpIconView::GetEntry( const Point& rDocPos )
+{
+ CheckBoundingRects();
+ SvLBoxEntry* pTarget = 0;
+ // Z-Order-Liste vom Ende her absuchen
+ USHORT nCount = pZOrderList->Count();
+ while( nCount )
+ {
+ nCount--;
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nCount));
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( pViewData->aRect.IsInside( rDocPos ) )
+ {
+ pTarget = pEntry;
+ break;
+ }
+ }
+ return pTarget;
+}
+
+SvLBoxEntry* SvImpIconView::GetNextEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry )
+{
+ CheckBoundingRects();
+ SvLBoxEntry* pTarget = 0;
+ USHORT nStartPos = pZOrderList->GetPos( (void*)pCurEntry );
+ if( nStartPos != USHRT_MAX )
+ {
+ USHORT nCount = pZOrderList->Count();
+ for( USHORT nCur = nStartPos+1; nCur < nCount; nCur++ )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nCur));
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( pViewData->aRect.IsInside( rDocPos ) )
+ {
+ pTarget = pEntry;
+ break;
+ }
+ }
+ }
+ return pTarget;
+}
+
+SvLBoxEntry* SvImpIconView::GetPrevEntry( const Point& rDocPos, SvLBoxEntry* pCurEntry )
+{
+ CheckBoundingRects();
+ SvLBoxEntry* pTarget = 0;
+ USHORT nStartPos = pZOrderList->GetPos( (void*)pCurEntry );
+ if( nStartPos != USHRT_MAX && nStartPos != 0 )
+ {
+ nStartPos--;
+ do
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nStartPos));
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( pViewData->aRect.IsInside( rDocPos ) )
+ {
+ pTarget = pEntry;
+ break;
+ }
+ } while( nStartPos > 0 );
+ }
+ return pTarget;
+}
+
+
+Point SvImpIconView::GetEntryPos( SvLBoxEntry* pEntry )
+{
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ DBG_ASSERT(pViewData,"Entry not in model")
+ return pViewData->aRect.TopLeft();
+}
+
+const Rectangle& SvImpIconView::GetBoundingRect( SvLBoxEntry* pEntry, SvIcnVwDataEntry* pViewData )
+{
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+ DBG_ASSERT(pViewData,"Entry not in model")
+ if( !IsBoundingRectValid( pViewData->aRect ))
+ FindBoundingRect( pEntry, pViewData );
+ return pViewData->aRect;
+}
+
+void SvImpIconView::SetSpaceBetweenEntries( long nHor, long nVer )
+{
+ nHorDist = nHor;
+ nVerDist = nVer;
+}
+
+Rectangle SvImpIconView::CalcBmpRect( SvLBoxEntry* pEntry, const Point* pPos,
+ SvIcnVwDataEntry* pViewData )
+{
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+
+ Rectangle aBound = GetBoundingRect( pEntry, pViewData );
+ if( pPos )
+ aBound.SetPos( *pPos );
+ Point aPos( aBound.TopLeft() );
+
+ switch( nViewMode )
+ {
+ case VIEWMODE_ICON:
+ {
+ aPos.X() += ( aBound.GetWidth() - nMaxBmpWidth ) / 2;
+ Size aSize( nMaxBmpWidth, nMaxBmpHeight );
+ // das Bitmap-Rechteck soll nicht das TextRect beruehren
+ aSize.Height() -= 3;
+ return Rectangle( aPos, aSize );
+ }
+
+ case VIEWMODE_NAME:
+ return Rectangle( aPos,
+ Size( nMaxBmpWidth, aBound.GetHeight() ));
+
+ case VIEWMODE_TEXT:
+ return Rectangle( aPos, aBound.GetSize() );
+
+ default:
+ {
+ Rectangle aRect;
+ return aRect;
+ }
+ }
+}
+
+Rectangle SvImpIconView::CalcTextRect( SvLBoxEntry* pEntry,
+ SvLBoxString* pItem, const Point* pPos, BOOL bForInplaceEdit,
+ SvIcnVwDataEntry* pViewData )
+{
+ long nBmpHeight, nBmpWidth;
+
+ if( !pItem )
+ pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+
+ Size aTextSize( GetItemSize( pView, pEntry, pItem, pViewData ));
+ aTextSize.Width() += 2*LROFFS_TEXT;
+
+ Size aContextBmpSize(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,pEntry));
+ Rectangle aBound = GetBoundingRect( pEntry, pViewData );
+ if( pPos )
+ aBound.SetPos( *pPos );
+ Point aPos( aBound.TopLeft() );
+
+ switch( nViewMode )
+ {
+ case VIEWMODE_ICON:
+ nBmpHeight = aContextBmpSize.Height();
+ if( nBmpHeight < nMaxBmpHeight )
+ nBmpHeight = nMaxBmpHeight;
+ aPos.Y() += nBmpHeight;
+
+ // beim Inplace-Editieren, spendieren wir ein bisschen mehr Platz
+ if( bForInplaceEdit )
+ {
+ // 20% rauf
+ long nMinWidth = (( (aContextBmpSize.Width()*10) / 100 ) * 2 ) +
+ aContextBmpSize.Width();
+ if( nMinWidth > aBound.GetWidth() )
+ nMinWidth = aBound.GetWidth();
+
+ if( aTextSize.Width() < nMinWidth )
+ aTextSize.Width() = nMinWidth;
+
+ // beim Inplace-Ed. darfs auch untere Eintraege ueberlappen
+ Rectangle aMaxGridTextRect = CalcMaxTextRect(pEntry, pViewData);
+#ifndef VCL
+ aMaxGridTextRect.Bottom() = LONG_MAX - 1;
+ aMaxGridTextRect = GetTextRect( pView, aMaxGridTextRect,pItem->GetText(), DRAWTEXT_FLAGS );
+#endif
+ Size aOptSize = aMaxGridTextRect.GetSize();
+ if( aOptSize.Height() > aTextSize.Height() )
+ aTextSize.Height() = aOptSize.Height();
+ }
+
+
+ aPos.X() += ( aBound.GetWidth() - aTextSize.Width() ) / 2;
+ break;
+
+ case VIEWMODE_NAME:
+ nBmpWidth = aContextBmpSize.Width();
+ if( nBmpWidth < nMaxBmpWidth )
+ nBmpWidth = nMaxBmpWidth;
+ aPos.X() += nBmpWidth;
+ // vertikal ausrichten
+ aPos.Y() += ( nBmpWidth - aTextSize.Height() ) / 2;
+ break;
+ }
+
+ Rectangle aRect( aPos, aTextSize );
+// KNALLT BEIM D&D, WENN GECLIPPT WIRD (In DrawText von Thomas)
+// ClipAtVirtOutRect( aRect );
+ return aRect;
+}
+
+
+long SvImpIconView::CalcBoundingWidth( SvLBoxEntry* pEntry,
+ const SvIcnVwDataEntry* pViewData ) const
+{
+ DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP),"No Bitmaps")
+ DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),"No Text")
+ long nStringWidth = GetItemSize( pView, pEntry, pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),pViewData).Width();
+ nStringWidth += 2*LROFFS_TEXT;
+ long nBmpWidth = pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,pEntry).Width();
+ long nWidth = 0;
+
+ switch( nViewMode )
+ {
+ case VIEWMODE_ICON:
+ nWidth = Max( nStringWidth, nBmpWidth );
+ nWidth = Max( nWidth, nMaxBmpWidth );
+ break;
+
+ case VIEWMODE_NAME:
+ nWidth = Max( nBmpWidth, nMaxBmpWidth );
+ nWidth += NAMEVIEW_OFFS_BMP_STRING; // Abstand Bitmap String
+ nWidth += nStringWidth;
+ break;
+
+ case VIEWMODE_TEXT:
+ nWidth = nStringWidth;
+ break;
+ }
+ return nWidth;
+}
+
+long SvImpIconView::CalcBoundingHeight( SvLBoxEntry* pEntry,
+ const SvIcnVwDataEntry* pViewData ) const
+{
+ DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP),"No Bitmaps")
+ DBG_ASSERT(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),"No Text")
+ long nStringHeight = GetItemSize(pView,pEntry,pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING),pViewData).Height();
+ long nBmpHeight = pEntry->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,pEntry).Height();
+ long nHeight = 0;
+
+ switch( nViewMode )
+ {
+ case VIEWMODE_ICON:
+ nHeight = Max( nBmpHeight, nMaxBmpHeight );
+ nHeight += ICONVIEW_OFFS_BMP_STRING; // Abstand Bitmap String
+ nHeight += nStringHeight;
+ break;
+
+ case VIEWMODE_NAME:
+ nHeight = Max( nBmpHeight, nMaxBmpHeight );
+ nHeight = Max( nHeight, nStringHeight );
+ break;
+
+ case VIEWMODE_TEXT:
+ nHeight = nStringHeight;
+ break;
+ }
+ if( nHeight > nMaxBoundHeight )
+ {
+ ((SvImpIconView*)this)->nMaxBoundHeight = nHeight;
+ ((SvImpIconView*)this)->aHorSBar.SetLineSize( nHeight / 2 );
+ ((SvImpIconView*)this)->aVerSBar.SetLineSize( nHeight / 2 );
+ }
+ return nHeight;
+}
+
+Size SvImpIconView::CalcBoundingSize( SvLBoxEntry* pEntry,
+ SvIcnVwDataEntry* pViewData ) const
+{
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+ return Size( CalcBoundingWidth(pEntry,pViewData),
+ CalcBoundingHeight(pEntry,pViewData) );
+}
+
+void SvImpIconView::RecalcAllBoundingRects()
+{
+ nMaxBoundHeight = 0;
+ pZOrderList->Remove(0, pZOrderList->Count() );
+ SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent );
+ while( pEntry )
+ {
+ FindBoundingRect( pEntry );
+ pZOrderList->Insert( pEntry, pZOrderList->Count() );
+ pEntry = pModel->NextSibling( pEntry );
+ }
+ bMustRecalcBoundingRects = FALSE;
+ AdjustScrollBars();
+}
+
+void SvImpIconView::RecalcAllBoundingRectsSmart()
+{
+ nMaxBoundHeight = 0;
+ pZOrderList->Remove(0, pZOrderList->Count() );
+ SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent );
+ while( pEntry )
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( IsBoundingRectValid( pViewData->aRect ))
+ {
+ Size aBoundSize( pViewData->aRect.GetSize() );
+ if( aBoundSize.Height() > nMaxBoundHeight )
+ nMaxBoundHeight = aBoundSize.Height();
+ pZOrderList->Insert( pEntry, pZOrderList->Count() );
+ }
+ else
+ {
+ FindBoundingRect( pEntry, pViewData );
+ }
+ pZOrderList->Insert( pEntry, pZOrderList->Count() );
+ pEntry = pModel->NextSibling( pEntry );
+ }
+ AdjustScrollBars();
+}
+
+void SvImpIconView::UpdateBoundingRects()
+{
+ SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent );
+ while( pEntry )
+ {
+ GetBoundingRect( pEntry );
+ pEntry = pModel->NextSibling( pEntry );
+ }
+}
+
+void SvImpIconView::FindBoundingRect( SvLBoxEntry* pEntry,
+ SvIcnVwDataEntry* pViewData )
+{
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+
+ Size aSize( CalcBoundingSize( pEntry, pViewData ) );
+ Point aPos;
+
+ DBG_ASSERT(!pViewData->IsEntryPosLocked(),"Locked entry pos in FindBoundingRect");
+ // damits in der IconView nicht drunter & drueber geht
+ if( pViewData->IsEntryPosLocked() && IsBoundingRectValid(pViewData->aRect) )
+ {
+ AdjustVirtSize( pViewData->aRect );
+ return;
+ }
+
+ aPos = FindNextEntryPos( aSize );
+
+ if( nFlags & F_GRIDMODE )
+ {
+ Rectangle aGridRect( aPos, Size(nGridDX, nGridDY) );
+ pViewData->aGridRect = aGridRect;
+ Center( pEntry, pViewData );
+ AdjustVirtSize( pViewData->aRect );
+ pImpCursor->SetGridUsed( pViewData->aRect );
+ }
+ else
+ {
+ pViewData->aRect = Rectangle( aPos, aSize );
+ AdjustVirtSize( pViewData->aRect );
+ }
+}
+
+
+void SvImpIconView::SetCursor( SvLBoxEntry* pEntry )
+{
+ if( pEntry == pCursor )
+ return;
+
+ ShowCursor( FALSE );
+ if( pCursor )
+ {
+ pView->SetEntryFocus( pCursor, FALSE );
+ if( pView->GetSelectionMode() == SINGLE_SELECTION )
+ pView->Select( pCursor, FALSE );
+ }
+ pCursor = pEntry;
+ ToTop( pCursor );
+ if( pCursor )
+ {
+ pView->SetEntryFocus(pCursor, TRUE );
+ if( pView->GetSelectionMode() == SINGLE_SELECTION )
+ pView->Select( pCursor, TRUE );
+ ShowCursor( TRUE );
+ }
+}
+
+
+void SvImpIconView::ShowCursor( BOOL bShow )
+{
+ if( !pCursor || !bShow || !pView->HasFocus() )
+ {
+ pView->HideFocus();
+ return;
+ }
+ Rectangle aRect ( CalcFocusRect( pCursor ) );
+ pView->ShowFocus( aRect );
+}
+
+
+void SvImpIconView::HideDDIcon()
+{
+ pView->Update();
+ ImpHideDDIcon();
+ pDDBufDev = pDDDev;
+ pDDDev = 0;
+}
+
+void SvImpIconView::ImpHideDDIcon()
+{
+ if( pDDDev )
+ {
+ Size aSize( pDDDev->GetOutputSizePixel() );
+ // pView restaurieren
+ pView->DrawOutDev( aDDLastRectPos, aSize, Point(), aSize, *pDDDev );
+ }
+}
+
+
+void SvImpIconView::ShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPosPix )
+{
+ pView->Update();
+ if( pRefEntry != pDDRefEntry )
+ {
+ DELETEZ(pDDDev);
+ DELETEZ(pDDBufDev);
+ }
+ BOOL bSelected = pView->SvListView::Select( pRefEntry, FALSE );
+ if( !pDDDev )
+ {
+ if( pDDBufDev )
+ {
+ // nicht bei jedem Move ein Device anlegen, da dies besonders
+ // auf Remote-Clients zu langsam ist
+ pDDDev = pDDBufDev;
+ pDDBufDev = 0;
+ }
+ else
+ {
+ pDDDev = new VirtualDevice( *pView );
+ pDDDev->SetFont( pView->GetFont() );
+ }
+ }
+ else
+ {
+ ImpHideDDIcon();
+ }
+ const Rectangle& rRect = GetBoundingRect( pRefEntry );
+ pDDDev->SetOutputSizePixel( rRect.GetSize() );
+
+ Point aPos( rPosPix );
+ CalcDocPos( aPos );
+
+ Size aSize( pDDDev->GetOutputSizePixel() );
+ pDDRefEntry = pRefEntry;
+ aDDLastEntryPos = aPos;
+ aDDLastRectPos = aPos;
+
+ // Hintergrund sichern
+ pDDDev->DrawOutDev( Point(), aSize, aPos, aSize, *pView );
+ // Icon in pView malen
+ nFlags |= F_NO_EMPHASIS;
+ PaintEntry( pRefEntry, aPos );
+ nFlags &= ~F_NO_EMPHASIS;
+ if( bSelected )
+ pView->SvListView::Select( pRefEntry, TRUE );
+}
+
+void SvImpIconView::HideShowDDIcon( SvLBoxEntry* pRefEntry, const Point& rPosPix )
+{
+/* In Notfaellen folgenden flackernden Code aktivieren:
+
+ HideDDIcon();
+ ShowDDIcon( pRefEntry, rPosPix );
+ return;
+*/
+ if( !pDDDev )
+ {
+ ShowDDIcon( pRefEntry, rPosPix );
+ return;
+ }
+
+ if( pRefEntry != pDDRefEntry )
+ {
+ HideDDIcon();
+ ShowDDIcon( pRefEntry, rPosPix );
+ return;
+ }
+
+ Point aEmptyPoint;
+
+ Point aCurEntryPos( rPosPix );
+ CalcDocPos( aCurEntryPos );
+
+ const Rectangle& rRect = GetBoundingRect( pRefEntry );
+ Size aEntrySize( rRect.GetSize() );
+ Rectangle aPrevEntryRect( aDDLastEntryPos, aEntrySize );
+ Rectangle aCurEntryRect( aCurEntryPos, aEntrySize );
+
+ if( !aPrevEntryRect.IsOver( aCurEntryRect ) )
+ {
+ HideDDIcon();
+ ShowDDIcon( pRefEntry, rPosPix );
+ return;
+ }
+
+ // Ueberlappung des neuen und alten D&D-Pointers!
+
+ Rectangle aFullRect( aPrevEntryRect.Union( aCurEntryRect ) );
+ if( !pDDTempDev )
+ {
+ pDDTempDev = new VirtualDevice( *pView );
+ pDDTempDev->SetFont( pView->GetFont() );
+ }
+
+ Size aFullSize( aFullRect.GetSize() );
+ Point aFullPos( aFullRect.TopLeft() );
+
+ pDDTempDev->SetOutputSizePixel( aFullSize );
+
+ // Hintergrund (mit dem alten D&D-Pointer!) sichern
+ pDDTempDev->DrawOutDev( aEmptyPoint, aFullSize, aFullPos, aFullSize, *pView );
+ // den alten Buffer in den neuen Buffer pasten
+ aDDLastRectPos = aDDLastRectPos - aFullPos;
+
+ pDDTempDev->DrawOutDev(
+ aDDLastRectPos,
+ pDDDev->GetOutputSizePixel(),
+ aEmptyPoint,
+ pDDDev->GetOutputSizePixel(),
+ *pDDDev );
+
+ // Swap
+ VirtualDevice* pTemp = pDDDev;
+ pDDDev = pDDTempDev;
+ pDDTempDev = pTemp;
+
+ // in den restaurierten Hintergrund den neuen D&D-Pointer zeichnen
+ pDDTempDev->SetOutputSizePixel( pDDDev->GetOutputSizePixel() );
+ pDDTempDev->DrawOutDev(
+ aEmptyPoint, aFullSize, aEmptyPoint, aFullSize, *pDDDev );
+ Point aRelPos = aCurEntryPos - aFullPos;
+ nFlags |= F_NO_EMPHASIS;
+ PaintEntry( pRefEntry, aRelPos, 0, pDDTempDev );
+ nFlags &= ~F_NO_EMPHASIS;
+
+ aDDLastRectPos = aFullPos;
+ aDDLastEntryPos = aCurEntryPos;
+
+ pView->DrawOutDev(
+ aDDLastRectPos,
+ pDDDev->GetOutputSizePixel(),
+ aEmptyPoint,
+ pDDDev->GetOutputSizePixel(),
+ *pDDTempDev );
+
+ BOOL bSelected = pView->SvListView::Select( pRefEntry, FALSE );
+ if( bSelected )
+ pView->SvListView::Select( pRefEntry, TRUE );
+}
+
+void SvImpIconView::ShowTargetEmphasis( SvLBoxEntry* pEntry, BOOL bShow )
+{
+ CheckBoundingRects();
+ Rectangle aRect;
+ if( pEntry != pCurParent &&
+ (pEntry->HasChilds() || pEntry->HasChildsOnDemand()) )
+ aRect = CalcBmpRect( pEntry );
+ else
+ {
+ aRect.SetSize( aOutputSize );
+ const MapMode& rMapMode = pView->GetMapMode();
+ Point aOrigin( rMapMode.GetOrigin());
+ aOrigin *= -1; // in Doc-Koord wandeln
+ aRect.SetPos( aOrigin );
+ aRect.Left()++; aRect.Top()++;
+ aRect.Right()--; aRect.Bottom()--;
+ }
+ ImpDrawXORRect( aRect );
+}
+
+BOOL SvImpIconView::NotifyMoving( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewPar, ULONG& rNewChildPos )
+{
+ if( pTarget == pCurParent && pModel->GetParent(pEntry) == pCurParent )
+ {
+ // D&D innerhalb einer Childlist
+ StopEditTimer();
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ Size aSize( pViewData->aRect.GetSize() );
+ Point aNewPos = FindNextEntryPos( aSize );
+ AdjustVirtSize( Rectangle( aNewPos, aSize ) );
+ SetEntryPos( pEntry, aNewPos, FALSE, TRUE );
+ return FALSE;
+ }
+ return pView->SvLBox::NotifyMoving(pTarget,pEntry,rpNewPar,rNewChildPos);
+}
+
+BOOL SvImpIconView::NotifyCopying( SvLBoxEntry* pTarget, SvLBoxEntry* pEntry,
+ SvLBoxEntry*& rpNewParent, ULONG& rNewChildPos )
+{
+ return pView->SvLBox::NotifyCopying(pTarget,pEntry,rpNewParent,rNewChildPos);
+}
+
+void SvImpIconView::WriteDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo)
+{
+ SvLBoxEntry* pCurEntry = GetCurEntry();
+ Point aEntryPos;
+ if( pCurEntry )
+ {
+ aEntryPos = rPos;
+ aEntryPos -= GetEntryPos( pCurEntry );
+ }
+ pInfo->nMouseRelX = aEntryPos.X();
+ pInfo->nMouseRelY = aEntryPos.Y();
+}
+
+void SvImpIconView::ReadDragServerInfo( const Point& rPos, SvLBoxDDInfo* pInfo )
+{
+ Point aDropPos( rPos );
+ aDropPos.X() -= pInfo->nMouseRelX;
+ aDropPos.Y() -= pInfo->nMouseRelY;
+ SetNextEntryPos( aDropPos );
+}
+
+void SvImpIconView::InvalidateBoundingRect( SvLBoxEntry* pEntry )
+{
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ InvalidateBoundingRect( pViewData->aRect );
+}
+
+void SvImpIconView::PrepareCommandEvent( const CommandEvent& rCEvt )
+{
+ aMouseMoveTimer.Stop();
+ StopEditTimer();
+ nFlags |= F_CMD_ARRIVED;
+ SvLBoxEntry* pEntry = pView->GetEntry( rCEvt.GetMousePosPixel(), TRUE );
+ if( (nFlags & F_DOWN_CTRL) && pEntry && !pView->IsSelected(pEntry) )
+ pView->Select( pEntry, TRUE );
+ nFlags &= ~(F_DOWN_CTRL | F_DOWN_DESELECT);
+}
+
+void SvImpIconView::Command( const CommandEvent& rCEvt )
+{
+ PrepareCommandEvent( rCEvt );
+ if( rCEvt.GetCommand() == COMMAND_STARTDRAG )
+ {
+ nFlags |= F_DRAG_SOURCE;
+ if( GetSelectionCount() )
+ {
+ ShowCursor( FALSE );
+ pView->BeginDrag( rCEvt.GetMousePosPixel() );
+ ShowCursor( TRUE );
+ }
+ nFlags &= (~F_DRAG_SOURCE);
+ }
+}
+
+void SvImpIconView::ToTop( SvLBoxEntry* pEntry )
+{
+ DBG_ASSERT(pZOrderList->GetPos(pEntry)!=0xffff,"ToTop:ZOrder?");
+ if( pZOrderList->GetObject( pZOrderList->Count() -1 ) != pEntry )
+ {
+ USHORT nPos = pZOrderList->GetPos( (void*)pEntry );
+ pZOrderList->Remove( nPos, 1 );
+ pZOrderList->Insert( pEntry, pZOrderList->Count() );
+ }
+}
+
+void SvImpIconView::SetCurParent( SvLBoxEntry* pNewParent )
+{
+ Clear();
+ pCurParent = pNewParent;
+ ImpArrange();
+}
+
+void SvImpIconView::ClipAtVirtOutRect( Rectangle& rRect ) const
+{
+ if( rRect.Bottom() >= aVirtOutputSize.Height() )
+ rRect.Bottom() = aVirtOutputSize.Height() - 1;
+ if( rRect.Right() >= aVirtOutputSize.Width() )
+ rRect.Right() = aVirtOutputSize.Width() - 1;
+ if( rRect.Top() < 0 )
+ rRect.Top() = 0;
+ if( rRect.Left() < 0 )
+ rRect.Left() = 0;
+}
+
+// rRect: Bereich des Dokumentes (in Dokumentkoordinaten), der
+// sichtbar gemacht werden soll.
+// bScrBar == TRUE: Das Rect wurde aufgrund eines ScrollBar-Events berechnet
+
+void SvImpIconView::MakeVisible( const Rectangle& rRect, BOOL bScrBar )
+{
+ Rectangle aRect( rRect );
+ ClipAtVirtOutRect( aRect );
+ MapMode aMapMode( pView->GetMapMode() );
+ Point aOrigin( aMapMode.GetOrigin() );
+ // in Dokumentkoordinate umwandeln
+ aOrigin *= -1;
+
+ Rectangle aOutputArea( aOrigin, aOutputSize );
+ if( aOutputArea.IsInside( aRect ) )
+ return; // ist schon sichtbar
+
+ long nDy;
+ if( aRect.Top() < aOutputArea.Top() )
+ {
+ // nach oben scrollen (nDy < 0)
+ nDy = aRect.Top() - aOutputArea.Top();
+ }
+ else if( aRect.Bottom() > aOutputArea.Bottom() )
+ {
+ // nach unten scrollen (nDy > 0)
+ nDy = aRect.Bottom() - aOutputArea.Bottom();
+ }
+ else
+ nDy = 0;
+
+ long nDx;
+ if( aRect.Left() < aOutputArea.Left() )
+ {
+ // nach links scrollen (nDx < 0)
+ nDx = aRect.Left() - aOutputArea.Left();
+ }
+ else if( aRect.Right() > aOutputArea.Right() )
+ {
+ // nach rechts scrollen (nDx > 0)
+ nDx = aRect.Right() - aOutputArea.Right();
+ }
+ else
+ nDx = 0;
+
+ aOrigin.X() += nDx;
+ aOrigin.Y() += nDy;
+ aOutputArea.SetPos( aOrigin );
+
+ pView->Update();
+
+ // Origin fuer SV invertieren (damit wir in
+ // Dokumentkoordinaten scrollen/painten koennen)
+ aOrigin *= -1;
+ aMapMode.SetOrigin( aOrigin );
+ pView->SetMapMode( aMapMode );
+
+ // in umgekehrte Richtung scrollen!
+ pView->Control::Scroll( -nDx, -nDy, aOutputArea, TRUE );
+ if( aHorSBar.IsVisible() || aVerSBar.IsVisible() )
+ {
+ if( !bScrBar )
+ {
+ aOrigin *= -1;
+ // Thumbs korrigieren
+ if(aHorSBar.IsVisible() && aHorSBar.GetThumbPos() != aOrigin.X())
+ aHorSBar.SetThumbPos( aOrigin.X() );
+ if(aVerSBar.IsVisible() && aVerSBar.GetThumbPos() != aOrigin.Y())
+ aVerSBar.SetThumbPos( aOrigin.Y() );
+ }
+ }
+ // pruefen, ob ScrollBars noch benoetigt werden
+ CheckScrollBars();
+ pView->Update();
+}
+
+
+SvLBoxEntry* SvImpIconView::GetNewCursor()
+{
+ SvLBoxEntry* pNewCursor;
+ if( pCursor )
+ {
+ pNewCursor = pImpCursor->GoLeftRight( pCursor, FALSE );
+ if( !pNewCursor )
+ {
+ pNewCursor = pImpCursor->GoLeftRight( pCursor, TRUE );
+ if( !pNewCursor )
+ {
+ pNewCursor = pImpCursor->GoUpDown( pCursor, FALSE );
+ if( !pNewCursor )
+ pNewCursor = pImpCursor->GoUpDown( pCursor, TRUE );
+ }
+ }
+ }
+ else
+ pNewCursor = pModel->FirstChild( pCurParent );
+ DBG_ASSERT(!pNewCursor|| (pCursor&&pCursor!=pNewCursor),"GetNewCursor failed");
+ return pNewCursor;
+}
+
+
+USHORT SvImpIconView:: GetSelectionCount() const
+{
+ USHORT nSelected = 0;
+ SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent);
+ while( pEntry )
+ {
+ if( pView->IsSelected( pEntry ) )
+ nSelected++;
+ pEntry = pModel->NextSibling( pEntry );
+ }
+ return nSelected;
+}
+
+
+void SvImpIconView::ToggleSelection( SvLBoxEntry* pEntry )
+{
+ BOOL bSel;
+ if( pView->IsSelected( pEntry ) )
+ bSel = FALSE;
+ else
+ bSel = TRUE;
+ pView->Select( pEntry, bSel );
+}
+
+void SvImpIconView::DeselectAllBut( SvLBoxEntry* pThisEntryNot )
+{
+ ClearSelectedRectList();
+ SvLBoxEntry* pEntry = pModel->FirstChild( pCurParent );
+ while( pEntry )
+ {
+ if( pEntry != pThisEntryNot && pView->IsSelected( pEntry ))
+ pView->Select( pEntry, FALSE );
+ pEntry = pModel->NextSibling( pEntry );
+ }
+}
+
+#define ICN_ROWS 50
+#define ICN_COLS 30
+
+ImpIcnCursor::ImpIcnCursor( SvImpIconView* pOwner )
+{
+ pView = pOwner;
+ pColumns = 0;
+ pRows = 0;
+ pCurEntry = 0;
+ nDeltaWidth = 0;
+ nDeltaHeight= 0;
+ nCols = 0;
+ nRows = 0;
+ nGridCols = 0;
+ nGridRows = 0;
+ pGridMap = 0;
+}
+
+ImpIcnCursor::~ImpIcnCursor()
+{
+ delete[] pColumns;
+ delete[] pRows;
+ delete pGridMap;
+}
+
+USHORT ImpIcnCursor::GetSortListPos( SvPtrarr* pList, long nValue,
+ int bVertical )
+{
+ USHORT nCount = (USHORT)pList->Count();
+ if( !nCount )
+ return 0;
+
+ USHORT nCurPos = 0;
+ long nPrevValue = LONG_MIN;
+ while( nCount )
+ {
+ const Rectangle& rRect=
+ pView->GetBoundingRect((SvLBoxEntry*)(pList->GetObject(nCurPos)));
+ long nCurValue;
+ if( bVertical )
+ nCurValue = rRect.Top();
+ else
+ nCurValue = rRect.Left();
+ if( nValue >= nPrevValue && nValue <= nCurValue )
+ return (USHORT)nCurPos;
+ nPrevValue = nCurValue;
+ nCount--;
+ nCurPos++;
+ }
+ return pList->Count();
+}
+
+void ImpIcnCursor::ImplCreate()
+{
+ pView->CheckBoundingRects();
+ DBG_ASSERT(pColumns==0&&pRows==0,"ImplCreate: Not cleared");
+
+ SetDeltas();
+
+ pColumns = new SvPtrarr[ nCols ];
+ pRows = new SvPtrarr[ nRows ];
+
+ DELETEZ(pGridMap);
+
+ SvLBoxTreeList* pModel = pView->pModel;
+ SvLBoxEntry* pEntry = pModel->FirstChild( pView->pCurParent );
+ while( pEntry )
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry);
+ // const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ Rectangle rRect( pView->CalcBmpRect( pEntry,0,pViewData ) );
+ short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / nDeltaHeight );
+ short nX = (short)( ((rRect.Left()+rRect.Right())/2) / nDeltaWidth );
+
+ // Rundungsfehler abfangen
+ if( nY >= nRows )
+ nY = nRows - 1;
+ if( nX >= nCols )
+ nX = nCols - 1;
+
+ USHORT nIns = GetSortListPos( &pColumns[nX], rRect.Top(), TRUE );
+ pColumns[ nX ].Insert( pEntry, nIns );
+
+ nIns = GetSortListPos( &pRows[nY], rRect.Left(), FALSE );
+ pRows[ nY ].Insert( pEntry, nIns );
+
+ pViewData->nX = nX;
+ pViewData->nY = nY;
+
+ pEntry = pModel->NextSibling( pEntry );
+ }
+}
+
+void ImpIcnCursor::CreateGridMap()
+{
+ if( pGridMap )
+ return;
+
+ const Size& rSize = pView->aVirtOutputSize;
+ long nWidth = rSize.Width();
+ if( nWidth < pView->nMaxVirtWidth )
+ nWidth = pView->nMaxVirtWidth;
+ nWidth -= 2*LROFFS_WINBORDER;
+ if( nWidth <= 0 )
+ nWidth = 1;
+
+ nGridDX = pView->nGridDX;
+ nGridDY = pView->nGridDY;
+
+ // Hinweis: Wegen der Abrundung bei Berechnung von nGridCols
+ // ist es moeglich, dass Eintrage nicht im Grid liegen. Diese
+ // wurden typischerweise manuell verschoben und gelockt
+ nGridCols = nWidth / nGridDX;
+ if( !nGridCols ) nGridCols = 1;
+
+ nGridRows = rSize.Height() / nGridDY;
+ // nRows nicht abrunden, da zur Vermeidung von Ueberlappungen
+ // das gesamte BoundingRect des Eintrags zur Markierung im Grid
+ // herangezogen wird.
+ if( (nGridRows * nGridDY) < rSize.Height() )
+ nGridRows++;
+ else if( !nGridRows )
+ nGridRows = 1;
+
+ //XXX
+ //nGridRows += 50; // in fuenfziger-Schritten
+
+ pGridMap = new BOOL[ nGridRows*nGridCols];
+ memset( (void*)pGridMap, 0, nGridRows*nGridCols );
+
+ SvLBoxTreeList* pModel = pView->pModel;
+ SvLBoxEntry* pEntry = pModel->FirstChild( pView->pCurParent );
+ while( pEntry )
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry);
+ const Rectangle& rRect = pViewData->aRect;
+ // nur, wenn der Entry schon plaziert ist
+ if( pView->IsBoundingRectValid( rRect ))
+ {
+ // Alle vom Eintrag beruehrten Grids kennzeichnen
+ SetGridUsed( pView->GetBoundingRect( pEntry, pViewData ) );
+ }
+ pEntry = pModel->NextSibling( pEntry );
+ }
+}
+
+BOOL ImpIcnCursor::GetGrid( const Point& rDocPos, USHORT& rGridX, USHORT& rGridY ) const
+{
+ Point aPos( rDocPos );
+ aPos.X() -= LROFFS_WINBORDER;
+ aPos.Y() -= TBOFFS_WINBORDER;
+ rGridX = (USHORT)(aPos.X() / nGridDX);
+ rGridY = (USHORT)(aPos.Y() / nGridDY);
+ BOOL bInGrid = TRUE;
+ if( rGridX >= nGridCols )
+ {
+ rGridX = nGridCols - 1;
+ bInGrid = FALSE;
+ }
+ if( rGridY >= nGridRows )
+ {
+ rGridY = nGridRows - 1;
+ if( !bInGrid )
+ return FALSE; // beide Koordinaten nicht im Grid
+ }
+ return TRUE;
+}
+
+void ImpIcnCursor::SetGridUsed( const Rectangle& rRect, BOOL bUsed )
+{
+ CreateGridMap();
+ USHORT nTLX, nTLY, nBRX, nBRY;
+
+ BOOL bTLInGrid = GetGrid( rRect.TopLeft(), nTLX, nTLY );
+ BOOL bBRInGrid = GetGrid( rRect.BottomRight(), nBRX, nBRY );
+
+ if( !bTLInGrid && !bBRInGrid )
+ return;
+
+ for( USHORT nCurY = nTLY; nCurY <= nBRY; nCurY++ )
+ {
+ for( USHORT nCurX = nTLX; nCurX <= nBRX; nCurX++ )
+ {
+ SetGridUsed( nCurX, nCurY, bUsed );
+ }
+ }
+}
+
+void ImpIcnCursor::Clear( BOOL bGridToo )
+{
+ if( pColumns )
+ {
+ delete[] pColumns;
+ delete[] pRows;
+ pColumns = 0;
+ pRows = 0;
+ pCurEntry = 0;
+ nDeltaWidth = 0;
+ nDeltaHeight = 0;
+ }
+ if( bGridToo && pGridMap )
+ {
+ DELETEZ(pGridMap);
+ nGridRows = 0;
+ nGridCols = 0;
+ }
+}
+
+SvLBoxEntry* ImpIcnCursor::SearchCol(USHORT nCol,USHORT nTop,USHORT nBottom,
+ USHORT nPref, BOOL bDown, BOOL bSimple )
+{
+ DBG_ASSERT(pCurEntry,"SearchCol: No reference entry");
+ SvPtrarr* pList = &(pColumns[ nCol ]);
+ USHORT nCount = pList->Count();
+ if( !nCount )
+ return 0;
+
+ const Rectangle& rRefRect = pView->GetBoundingRect(pCurEntry);
+
+ if( bSimple )
+ {
+ USHORT nListPos = pList->GetPos( pCurEntry );
+ DBG_ASSERT(nListPos!=0xffff,"Entry not in Col-List");
+ if( bDown )
+ {
+ while( nListPos < nCount-1 )
+ {
+ nListPos++;
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos );
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ if( rRect.Top() > rRefRect.Top() )
+ return pEntry;
+ }
+ return 0;
+ }
+ else
+ {
+ while( nListPos )
+ {
+ nListPos--;
+ if( nListPos < nCount )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos );
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ if( rRect.Top() < rRefRect.Top() )
+ return pEntry;
+ }
+ }
+ return 0;
+ }
+ }
+
+ if( nTop > nBottom )
+ {
+ USHORT nTemp = nTop;
+ nTop = nBottom;
+ nBottom = nTemp;
+ }
+ long nMinDistance = LONG_MAX;
+ SvLBoxEntry* pResult = 0;
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pList->GetObject( nCur ));
+ if( pEntry != pCurEntry )
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry);
+ USHORT nY = pViewData->nY;
+ if( nY >= nTop && nY <= nBottom )
+ {
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ long nDistance = rRect.Top() - rRefRect.Top();
+ if( nDistance < 0 )
+ nDistance *= -1;
+ if( nDistance && nDistance < nMinDistance )
+ {
+ nMinDistance = nDistance;
+ pResult = pEntry;
+ }
+ }
+ }
+ }
+ return pResult;
+}
+
+SvLBoxEntry* ImpIcnCursor::SearchRow(USHORT nRow,USHORT nLeft,USHORT nRight,
+ USHORT nPref, BOOL bRight, BOOL bSimple )
+{
+ DBG_ASSERT(pCurEntry,"SearchRow: No reference entry");
+ SvPtrarr* pList = &(pRows[ nRow ]);
+ USHORT nCount = pList->Count();
+ if( !nCount )
+ return 0;
+
+ const Rectangle& rRefRect = pView->GetBoundingRect(pCurEntry);
+
+ if( bSimple )
+ {
+ USHORT nListPos = pList->GetPos( pCurEntry );
+ DBG_ASSERT(nListPos!=0xffff,"Entry not in Row-List");
+ if( bRight )
+ {
+ while( nListPos < nCount-1 )
+ {
+ nListPos++;
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos );
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ if( rRect.Left() > rRefRect.Left() )
+ return pEntry;
+ }
+ return 0;
+ }
+ else
+ {
+ while( nListPos )
+ {
+ nListPos--;
+ if( nListPos < nCount )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)pList->GetObject( nListPos );
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ if( rRect.Left() < rRefRect.Left() )
+ return pEntry;
+ }
+ }
+ return 0;
+ }
+
+ }
+ if( nRight < nLeft )
+ {
+ USHORT nTemp = nRight;
+ nRight = nLeft;
+ nLeft = nTemp;
+ }
+ long nMinDistance = LONG_MAX;
+ SvLBoxEntry* pResult = 0;
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pList->GetObject( nCur ));
+ if( pEntry != pCurEntry )
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry);
+ USHORT nX = pViewData->nX;
+ if( nX >= nLeft && nX <= nRight )
+ {
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ long nDistance = rRect.Left() - rRefRect.Left();
+ if( nDistance < 0 )
+ nDistance *= -1;
+ if( nDistance && nDistance < nMinDistance )
+ {
+ nMinDistance = nDistance;
+ pResult = pEntry;
+ }
+ }
+ }
+ }
+ return pResult;
+}
+
+
+
+/*
+ Sucht ab dem uebergebenen Eintrag den naechsten rechts- bzw.
+ linksstehenden. Suchverfahren am Beispiel bRight = TRUE:
+
+ c
+ b c
+ a b c
+ S 1 1 1 ====> Suchrichtung
+ a b c
+ b c
+ c
+
+ S : Startposition
+ 1 : erstes Suchrechteck
+ a,b,c : 2., 3., 4. Suchrechteck
+*/
+
+SvLBoxEntry* ImpIcnCursor::GoLeftRight( SvLBoxEntry* pEntry, BOOL bRight )
+{
+ SvLBoxEntry* pResult;
+ pCurEntry = pEntry;
+ Create();
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry);
+ USHORT nY = pViewData->nY;
+ USHORT nX = pViewData->nX;
+ DBG_ASSERT(nY< nRows,"GoLeftRight:Bad column");
+ DBG_ASSERT(nX< nCols,"GoLeftRight:Bad row");
+ // Nachbar auf gleicher Zeile ?
+ if( bRight )
+ pResult = SearchRow( nY, nX ,nCols-1, nX, TRUE, TRUE );
+ else
+ pResult = SearchRow( nY, nX ,0, nX, FALSE, TRUE );
+ if( pResult )
+ return pResult;
+
+ long nCurCol = nX;
+
+ long nColOffs, nLastCol;
+ if( bRight )
+ {
+ nColOffs = 1;
+ nLastCol = nCols;
+ }
+ else
+ {
+ nColOffs = -1;
+ nLastCol = -1; // 0-1
+ }
+
+ USHORT nRowMin = nY;
+ USHORT nRowMax = nY;
+ do
+ {
+ SvLBoxEntry* pEntry = SearchCol((USHORT)nCurCol,nRowMin,nRowMax,nY,TRUE, FALSE);
+ if( pEntry )
+ return pEntry;
+ if( nRowMin )
+ nRowMin--;
+ if( nRowMax < (nRows-1))
+ nRowMax++;
+ nCurCol += nColOffs;
+ } while( nCurCol != nLastCol );
+ return 0;
+}
+
+SvLBoxEntry* ImpIcnCursor::GoUpDown( SvLBoxEntry* pEntry, BOOL bDown)
+{
+ SvLBoxEntry* pResult;
+ pCurEntry = pEntry;
+ Create();
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA2(pEntry);
+ USHORT nY = pViewData->nY;
+ USHORT nX = pViewData->nX;
+ DBG_ASSERT(nY<nRows,"GoUpDown:Bad column");
+ DBG_ASSERT(nX<nCols,"GoUpDown:Bad row");
+
+ // Nachbar in gleicher Spalte ?
+ if( bDown )
+ pResult = SearchCol( nX, nY ,nRows-1, nY, TRUE, TRUE );
+ else
+ pResult = SearchCol( nX, nY ,0, nY, FALSE, TRUE );
+ if( pResult )
+ return pResult;
+
+ long nCurRow = nY;
+
+ long nRowOffs, nLastRow;
+ if( bDown )
+ {
+ nRowOffs = 1;
+ nLastRow = nRows;
+ }
+ else
+ {
+ nRowOffs = -1;
+ nLastRow = -1; // 0-1
+ }
+
+ USHORT nColMin = nX;
+ USHORT nColMax = nX;
+ do
+ {
+ SvLBoxEntry* pEntry = SearchRow((USHORT)nCurRow,nColMin,nColMax,nX,TRUE, FALSE);
+ if( pEntry )
+ return pEntry;
+ if( nColMin )
+ nColMin--;
+ if( nColMax < (nCols-1))
+ nColMax++;
+ nCurRow += nRowOffs;
+ } while( nCurRow != nLastRow );
+ return 0;
+}
+
+void ImpIcnCursor::SetDeltas()
+{
+ const Size& rSize = pView->aVirtOutputSize;
+ if( pView->nFlags & F_GRIDMODE )
+ {
+ nGridDX = pView->nGridDX;
+ nGridDY = pView->nGridDY;
+ }
+ else
+ {
+ nGridDX = 20;
+ nGridDY = 20;
+ }
+ nCols = rSize.Width() / nGridDX;
+ if( !nCols )
+ nCols = 1;
+ nRows = rSize.Height() / nGridDY;
+ if( (nRows * nGridDY) < rSize.Height() )
+ nRows++;
+ if( !nRows )
+ nRows = 1;
+
+ nDeltaWidth = (short)(rSize.Width() / nCols);
+ nDeltaHeight = (short)(rSize.Height() / nRows);
+ if( !nDeltaHeight )
+ {
+ nDeltaHeight = 1;
+ DBG_WARNING("SetDeltas:Bad height");
+ }
+ if( !nDeltaWidth )
+ {
+ nDeltaWidth = 1;
+ DBG_WARNING("SetDeltas:Bad width");
+ }
+}
+
+
+void ImpIcnCursor::ExpandGrid()
+{
+ if( pGridMap )
+ {
+ long nNewGridRows = nGridRows + 20;
+ unsigned char* pTempMap = new unsigned char[ nNewGridRows * nGridCols ];
+ memset( pTempMap, nNewGridRows * nGridCols, 0 );
+ memcpy( pTempMap, pGridMap, nGridRows * nGridCols );
+ delete pGridMap;
+ pGridMap = pTempMap;
+ nGridRows = nNewGridRows;
+ }
+}
+
+BOOL ImpIcnCursor::FindEmptyGridRect( Rectangle& rRect )
+{
+ CreateGridMap();
+ USHORT nCount = (USHORT)(nGridCols * nGridRows);
+ if( !nCount )
+ return FALSE;
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ if( !pGridMap[ nCur ] )
+ {
+ USHORT nCol = (USHORT)(nCur % nGridCols);
+ USHORT nRow = (USHORT)(nCur / nGridCols);
+ rRect.Top() = nRow * nGridDY + TBOFFS_WINBORDER;
+ rRect.Bottom() = rRect.Top() + nGridDY;
+ rRect.Left() = nCol * nGridDX+ LROFFS_WINBORDER;
+ rRect.Right() = rRect.Left() + nGridDX;
+ SetGridUsed( nCol, nRow, TRUE );
+
+ //XXX
+ //if( nRow + 5 > nGridRows )
+ // ExpandGrid();
+ DBG_ASSERT(pGridMap[nCur],"SetGridUsed failed");
+ return TRUE;
+ }
+ }
+ // Gridmap ist voll: Um eine Zeile erweitern
+ rRect.Top() = nGridRows * nGridDY + TBOFFS_WINBORDER;
+ rRect.Bottom() = rRect.Top() + nGridDY;
+ rRect.Left() = LROFFS_WINBORDER;
+ rRect.Right() = rRect.Left() + nGridDX;
+ return FALSE;
+ //XXX
+ //ExpandGrid();
+ //return TRUE;
+}
+
+void ImpIcnCursor::CreateGridAjustData( SvPtrarr& rLists, SvLBoxEntry* pRefEntry)
+{
+ if( !pRefEntry )
+ {
+ USHORT nRows = (USHORT)(pView->aVirtOutputSize.Height() / pView->nGridDY);
+ nRows++; // wg. Abrundung!
+
+ if( !nRows )
+ return;
+ for( USHORT nCurList = 0; nCurList < nRows; nCurList++ )
+ {
+ SvPtrarr* pRow = new SvPtrarr;
+ rLists.Insert( (void*)pRow, nCurList );
+ }
+ SvLBoxEntry* pEntry = pView->pModel->FirstChild( pView->pCurParent );
+ while( pEntry )
+ {
+ const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / pView->nGridDY );
+ USHORT nIns = GetSortListPos((SvPtrarr*)rLists[nY],rRect.Left(),FALSE);
+ ((SvPtrarr*)rLists[ nY ])->Insert( pEntry, nIns );
+ pEntry = pView->pModel->NextSibling( pEntry );
+ }
+ }
+ else
+ {
+ // Aufbau eines hor. "Schlauchs" auf der RefEntry-Zeile
+
+ // UEBERLEGEN: BoundingRect nehmen wg. Ueberlappungen???
+
+ Rectangle rRefRect( pView->CalcBmpRect( pRefEntry ) );
+ //const Rectangle& rRefRect = pView->GetBoundingRect( pRefEntry );
+ short nRefRow = (short)( ((rRefRect.Top()+rRefRect.Bottom())/2) / pView->nGridDY );
+ SvPtrarr* pRow = new SvPtrarr;
+ rLists.Insert( (void*)pRow, 0 );
+ SvLBoxEntry* pEntry = pView->pModel->FirstChild( pView->pCurParent );
+ while( pEntry )
+ {
+ Rectangle rRect( pView->CalcBmpRect(pEntry) );
+ //const Rectangle& rRect = pView->GetBoundingRect( pEntry );
+ short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / pView->nGridDY );
+ if( nY == nRefRow )
+ {
+ USHORT nIns = GetSortListPos( pRow, rRect.Left(), FALSE );
+ pRow->Insert( pEntry, nIns );
+ }
+ pEntry = pView->pModel->NextSibling( pEntry );
+ }
+ }
+}
+
+//static
+void ImpIcnCursor::DestroyGridAdjustData( SvPtrarr& rLists )
+{
+ USHORT nCount = rLists.Count();
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ SvPtrarr* pArr = (SvPtrarr*)rLists[ nCur ];
+ delete pArr;
+ }
+ rLists.Remove( 0, rLists.Count() );
+}
+
+void SvImpIconView::SetGrid( long nDX, long nDY )
+{
+ nGridDX = nDX;
+ nGridDY = nDY;
+ nFlags |= F_GRIDMODE;
+}
+
+Rectangle SvImpIconView::CalcMaxTextRect( const SvLBoxEntry* pEntry,
+ const SvIcnVwDataEntry* pViewData ) const
+{
+ Rectangle aRect = pViewData->aGridRect;
+ long nBmpHeight = ((SvLBoxEntry*)pEntry)->GetFirstItem(SV_ITEM_ID_LBOXCONTEXTBMP)->GetSize(pView,(SvLBoxEntry*)pEntry).Height();
+ aRect.Top() += nBmpHeight;
+ aRect.Top() += ICONVIEW_OFFS_BMP_STRING;
+ if( aRect.Top() > aRect.Bottom())
+ aRect.Top() = aRect.Bottom();
+ aRect.Left() += LROFFS_BOUND;
+ aRect.Left()++;
+ aRect.Right() -= LROFFS_BOUND;
+ aRect.Right()--;
+ if( aRect.Left() > aRect.Right())
+ aRect.Left() = aRect.Right();
+ if( GetTextMode( pEntry, pViewData ) == ShowTextFull )
+ aRect.Bottom() = LONG_MAX;
+ return aRect;
+}
+
+void SvImpIconView::Center( SvLBoxEntry* pEntry,
+ SvIcnVwDataEntry* pViewData ) const
+{
+ SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ const String& rEntryText = pStringItem->GetText();
+
+ Rectangle aTextRect = CalcMaxTextRect(pEntry,pViewData);
+ aTextRect = GetTextRect( pView, aTextRect, rEntryText, DRAWTEXT_FLAGS );
+ pViewData->aTextSize = aTextRect.GetSize();
+
+ pViewData->aRect = pViewData->aGridRect;
+ Size aSize( CalcBoundingSize( pEntry, pViewData ) );
+ long nBorder = pViewData->aGridRect.GetWidth() - aSize.Width();
+ pViewData->aRect.Left() += nBorder / 2;
+ pViewData->aRect.Right() -= nBorder / 2;
+ pViewData->aRect.Bottom() = pViewData->aRect.Top() + aSize.Height();
+}
+
+
+// Die Deltas entsprechen Offsets, um die die View auf dem Doc verschoben wird
+// links, hoch: Offsets < 0
+// rechts, runter: Offsets > 0
+void SvImpIconView::Scroll( long nDeltaX, long nDeltaY, BOOL bScrollBar )
+{
+ const MapMode& rMapMode = pView->GetMapMode();
+ Point aOrigin( rMapMode.GetOrigin() );
+ // in Dokumentkoordinate umwandeln
+ aOrigin *= -1;
+ aOrigin.Y() += nDeltaY;
+ aOrigin.X() += nDeltaX;
+ Rectangle aRect( aOrigin, aOutputSize );
+ MakeVisible( aRect, bScrollBar );
+}
+
+
+const Size& SvImpIconView::GetItemSize( SvIconView* pView,
+ SvLBoxEntry* pEntry, SvLBoxItem* pItem, const SvIcnVwDataEntry* pViewData) const
+{
+ if( (nFlags & F_GRIDMODE) && pItem->IsA() == SV_ITEM_ID_LBOXSTRING )
+ {
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(pEntry);
+ return pViewData->aTextSize;
+ }
+ else
+ return pItem->GetSize( pView, pEntry );
+}
+
+Rectangle SvImpIconView::CalcFocusRect( SvLBoxEntry* pEntry )
+{
+#if !defined(OS2)
+ SvLBoxString* pStringItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ DBG_ASSERT(pStringItem,"Text not set");
+ return CalcTextRect( pEntry, pStringItem );
+#else
+ return CalcBmpRect( pEntry );
+#endif
+}
+
+
+void SvImpIconView::SelectRect( const Rectangle& rRect, BOOL bAdd,
+ SvPtrarr* pOtherRects, short nBorderOffs )
+{
+ if( !pZOrderList || !pZOrderList->Count() )
+ return;
+
+ CheckBoundingRects();
+ pView->Update();
+ USHORT nCount = pZOrderList->Count();
+
+ Rectangle aRect( rRect );
+ aRect.Justify();
+ if( nBorderOffs )
+ {
+ aRect.Left() -= nBorderOffs;
+ aRect.Right() += nBorderOffs;
+ aRect.Top() -= nBorderOffs;
+ aRect.Bottom() += nBorderOffs;
+ }
+ BOOL bCalcOverlap = (bAdd && pOtherRects && pOtherRects->Count()) ? TRUE : FALSE;
+
+ for( USHORT nPos = 0; nPos < nCount; nPos++ )
+ {
+ SvLBoxEntry* pEntry = (SvLBoxEntry*)(pZOrderList->GetObject(nPos ));
+
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ DBG_ASSERT(pViewData,"Entry not in model")
+ if( !IsBoundingRectValid( pViewData->aRect ))
+ FindBoundingRect( pEntry, pViewData );
+ const Rectangle& rBoundRect = pViewData->aRect;
+ BOOL bSelected = pViewData->IsSelected();
+
+ BOOL bOverlaps;
+ if( bCalcOverlap )
+ bOverlaps = IsOver( pOtherRects, rBoundRect );
+ else
+ bOverlaps = FALSE;
+ BOOL bOver = aRect.IsOver( rBoundRect );
+
+ if( bOver && !bOverlaps )
+ {
+ // Ist im neuen Selektionsrechteck und in keinem alten
+ // => selektieren
+ if( !bSelected )
+ pView->Select( pEntry, TRUE );
+ }
+ else if( !bAdd )
+ {
+ // ist ausserhalb des Selektionsrechtecks
+ // => Selektion entfernen
+ if( bSelected )
+ pView->Select( pEntry, FALSE );
+ }
+ else if( bAdd && bOverlaps )
+ {
+ // Der Eintrag befindet sich in einem alten (=>Aufspannen
+ // mehrerer Rechtecke mit Ctrl!) Selektionsrechteck
+
+ // Hier ist noch ein Bug! Der Selektionsstatus eines Eintrags
+ // in einem vorherigen Rechteck, muss restauriert werden, wenn
+ // er vom aktuellen Selektionsrechteck beruehrt wurde, jetzt aber
+ // nicht mehr in ihm liegt. Ich gehe hier der Einfachheit halber
+ // pauschal davon aus, dass die Eintraege in den alten Rechtecken
+ // alle selektiert sind. Ebenso ist es falsch, die Schnittmenge
+ // nur zu deselektieren.
+ // Loesungsmoeglichkeit: Snapshot der Selektion vor dem Auf-
+ // spannen des Rechtecks merken
+ if( rBoundRect.IsOver( rRect))
+ {
+ // Schnittmenge zwischen alten Rects & aktuellem Rect desel.
+ if( bSelected )
+ pView->Select( pEntry, FALSE );
+ }
+ else
+ {
+ // Eintrag eines alten Rects selektieren
+ if( !bSelected )
+ pView->Select( pEntry, TRUE );
+ }
+ }
+ else if( !bOver && bSelected )
+ {
+ // Der Eintrag liegt voellig ausserhalb und wird deshalb desel.
+ pView->Select( pEntry, FALSE );
+ }
+ }
+ pView->Update();
+}
+
+BOOL SvImpIconView::IsOver( SvPtrarr* pRectList, const Rectangle& rBoundRect ) const
+{
+ USHORT nCount = pRectList->Count();
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ Rectangle* pRect = (Rectangle*)pRectList->GetObject( nCur );
+ if( rBoundRect.IsOver( *pRect ))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void SvImpIconView::AddSelectedRect( const Rectangle& rRect, short nBorderOffs )
+{
+ Rectangle* pRect = new Rectangle( rRect );
+ pRect->Justify();
+ if( nBorderOffs )
+ {
+ pRect->Left() -= nBorderOffs;
+ pRect->Right() += nBorderOffs;
+ pRect->Top() -= nBorderOffs;
+ pRect->Bottom() += nBorderOffs;
+ }
+ aSelectedRectList.Insert( (void*)pRect, aSelectedRectList.Count() );
+}
+
+void SvImpIconView::ClearSelectedRectList()
+{
+ USHORT nCount = aSelectedRectList.Count();
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ Rectangle* pRect = (Rectangle*)aSelectedRectList.GetObject( nCur );
+ delete pRect;
+ }
+ aSelectedRectList.Remove( 0, aSelectedRectList.Count() );
+}
+
+
+void SvImpIconView::DrawSelectionRect( const Rectangle& rRect )
+{
+ pView->HideTracking();
+ nFlags |= F_SELRECT_VISIBLE;
+ pView->ShowTracking( rRect, SHOWTRACK_SMALL | SHOWTRACK_WINDOW );
+ aCurSelectionRect = rRect;
+}
+
+void SvImpIconView::HideSelectionRect()
+{
+ if( nFlags & F_SELRECT_VISIBLE )
+ {
+ pView->HideTracking();
+ nFlags &= ~F_SELRECT_VISIBLE;
+ }
+}
+
+void SvImpIconView::ImpDrawXORRect( const Rectangle& rRect )
+{
+ RasterOp eOldOp = pView->GetRasterOp();
+ pView->SetRasterOp( ROP_XOR );
+ Color aOldColor = pView->GetFillColor();
+ pView->SetFillColor();
+ pView->DrawRect( rRect );
+ pView->SetFillColor( aOldColor );
+ pView->SetRasterOp( eOldOp );
+}
+
+void SvImpIconView::CalcScrollOffsets( const Point& rPosPixel,
+ long& rX, long& rY, BOOL bInDragDrop, USHORT nBorderWidth)
+{
+ // Scrolling der View, falls sich der Mauszeiger im Grenzbereich des
+ // Fensters befindet
+ long nPixelToScrollX = 0;
+ long nPixelToScrollY = 0;
+ Size aWndSize = aOutputSize;
+
+ nBorderWidth = (USHORT)(Min( (long)(aWndSize.Height()-1), (long)nBorderWidth ));
+ nBorderWidth = (USHORT)(Min( (long)(aWndSize.Width()-1), (long)nBorderWidth ));
+
+ if ( rPosPixel.X() < nBorderWidth )
+ {
+ if( bInDragDrop )
+ nPixelToScrollX = -DD_SCROLL_PIXEL;
+ else
+ nPixelToScrollX = rPosPixel.X()- nBorderWidth;
+ }
+ else if ( rPosPixel.X() > aWndSize.Width() - nBorderWidth )
+ {
+ if( bInDragDrop )
+ nPixelToScrollX = DD_SCROLL_PIXEL;
+ else
+ nPixelToScrollX = rPosPixel.X() - (aWndSize.Width() - nBorderWidth);
+ }
+ if ( rPosPixel.Y() < nBorderWidth )
+ {
+ if( bInDragDrop )
+ nPixelToScrollY = -DD_SCROLL_PIXEL;
+ else
+ nPixelToScrollY = rPosPixel.Y() - nBorderWidth;
+ }
+ else if ( rPosPixel.Y() > aWndSize.Height() - nBorderWidth )
+ {
+ if( bInDragDrop )
+ nPixelToScrollY = DD_SCROLL_PIXEL;
+ else
+ nPixelToScrollY = rPosPixel.Y() - (aWndSize.Height() - nBorderWidth);
+ }
+
+ rX = nPixelToScrollX;
+ rY = nPixelToScrollY;
+}
+
+IMPL_LINK(SvImpIconView, MouseMoveTimeoutHdl, Timer*, pTimer )
+{
+ pTimer->Start();
+ MouseMove( aMouseMoveEvent );
+ return 0;
+}
+
+void SvImpIconView::EndTracking()
+{
+ pView->ReleaseMouse();
+ if( nFlags & F_RUBBERING )
+ {
+ aMouseMoveTimer.Stop();
+ nFlags &= ~(F_RUBBERING | F_ADD_MODE);
+ }
+}
+
+BOOL SvImpIconView::IsTextHit( SvLBoxEntry* pEntry, const Point& rDocPos )
+{
+ SvLBoxString* pItem = (SvLBoxString*)(pEntry->GetFirstItem(SV_ITEM_ID_LBOXSTRING));
+ if( pItem )
+ {
+ Rectangle aRect( CalcTextRect( pEntry, pItem ));
+ if( aRect.IsInside( rDocPos ) )
+ return TRUE;
+ }
+ return FALSE;
+}
+
+IMPL_LINK(SvImpIconView, EditTimeoutHdl, Timer*, pTimer )
+{
+ SvLBoxEntry* pEntry = GetCurEntry();
+ if( pView->IsInplaceEditingEnabled() && pEntry &&
+ pView->IsSelected( pEntry ))
+ {
+ pView->EditEntry( pEntry );
+ }
+ return 0;
+}
+
+
+//
+// Funktionen zum Ausrichten der Eintraege am Grid
+//
+
+// pStart == 0: Alle Eintraege werden ausgerichtet
+// sonst: Alle Eintraege der Zeile ab einschliesslich pStart werden ausgerichtet
+void SvImpIconView::AdjustAtGrid( SvLBoxEntry* pStart )
+{
+ SvPtrarr aLists;
+ pImpCursor->CreateGridAjustData( aLists, pStart );
+ USHORT nCount = aLists.Count();
+ for( USHORT nCur = 0; nCur < nCount; nCur++ )
+ {
+ AdjustAtGrid( *(SvPtrarr*)aLists[ nCur ], pStart );
+ }
+ ImpIcnCursor::DestroyGridAdjustData( aLists );
+ CheckScrollBars();
+}
+
+// Richtet eine Zeile aus, erweitert ggf. die Breite; Bricht die Zeile nicht um
+void SvImpIconView::AdjustAtGrid( const SvPtrarr& rRow, SvLBoxEntry* pStart )
+{
+ if( !rRow.Count() )
+ return;
+
+ BOOL bGo;
+ if( !pStart )
+ bGo = TRUE;
+ else
+ bGo = FALSE;
+
+ long nCurRight = 0;
+ for( USHORT nCur = 0; nCur < rRow.Count(); nCur++ )
+ {
+ SvLBoxEntry* pCur = (SvLBoxEntry*)rRow[ nCur ];
+ if( !bGo && pCur == pStart )
+ bGo = TRUE;
+
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pCur);
+ // Massgebend (fuer das menschliche Auge) ist die Bitmap, da sonst
+ // durch lange Texte der Eintrag stark springen kann
+ const Rectangle& rBoundRect = GetBoundingRect( pCur, pViewData );
+ Rectangle aCenterRect( CalcBmpRect( pCur, 0, pViewData ));
+ if( bGo && !pViewData->IsEntryPosLocked() )
+ {
+ long nWidth = aCenterRect.GetSize().Width();
+ Point aNewPos( AdjustAtGrid( aCenterRect, rBoundRect ) );
+ while( aNewPos.X() < nCurRight )
+ aNewPos.X() += nGridDX;
+ if( aNewPos != rBoundRect.TopLeft() )
+ SetEntryPos( pCur, aNewPos );
+ nCurRight = aNewPos.X() + nWidth;
+ }
+ else
+ {
+ nCurRight = rBoundRect.Right();
+ }
+ }
+}
+
+// Richtet Rect am Grid aus, garantiert jedoch nicht, dass die
+// neue Pos. frei ist. Die Pos. kann fuer SetEntryPos verwendet werden.
+// Das CenterRect beschreibt den Teil des BoundRects, der fuer
+// die Berechnung des Ziel-Rechtecks verwendet wird.
+Point SvImpIconView::AdjustAtGrid( const Rectangle& rCenterRect,
+ const Rectangle& rBoundRect ) const
+{
+ Point aPos( rCenterRect.TopLeft() );
+ Size aSize( rCenterRect.GetSize() );
+
+ aPos.X() -= LROFFS_WINBORDER;
+ aPos.Y() -= TBOFFS_WINBORDER;
+
+ // align (ref ist mitte des rects)
+ short nGridX = (short)((aPos.X()+(aSize.Width()/2)) / nGridDX);
+ short nGridY = (short)((aPos.Y()+(aSize.Height()/2)) / nGridDY);
+ aPos.X() = nGridX * nGridDX;
+ aPos.Y() = nGridY * nGridDY;
+ // hor. center
+ aPos.X() += (nGridDX - rBoundRect.GetSize().Width() ) / 2;
+
+ aPos.X() += LROFFS_WINBORDER;
+ aPos.Y() += TBOFFS_WINBORDER;
+
+ return aPos;
+}
+
+
+void SvImpIconView::SetTextMode( SvIconViewTextMode eMode, SvLBoxEntry* pEntry )
+{
+ if( !pEntry )
+ {
+ if( eTextMode != eMode )
+ {
+ if( eTextMode == ShowTextDontKnow )
+ eTextMode = ShowTextShort;
+ eTextMode = eMode;
+ pView->Arrange();
+ }
+ }
+ else
+ {
+ SvIcnVwDataEntry* pViewData = ICNVIEWDATA(pEntry);
+ if( pViewData->eTextMode != eMode )
+ {
+ pViewData->eTextMode = eMode;
+ pModel->InvalidateEntry( pEntry );
+ AdjustVirtSize( pViewData->aRect );
+ }
+ }
+}
+
+SvIconViewTextMode SvImpIconView::GetTextMode( const SvLBoxEntry* pEntry,
+ const SvIcnVwDataEntry* pViewData ) const
+{
+ if( !pEntry )
+ return eTextMode;
+ else
+ {
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(((SvLBoxEntry*)pEntry));
+ return pViewData->GetTextMode();
+ }
+}
+
+SvIconViewTextMode SvImpIconView::GetEntryTextModeSmart( const SvLBoxEntry* pEntry,
+ const SvIcnVwDataEntry* pViewData ) const
+{
+ DBG_ASSERT(pEntry,"GetEntryTextModeSmart: Entry not set");
+ if( !pViewData )
+ pViewData = ICNVIEWDATA(((SvLBoxEntry*)pEntry));
+ SvIconViewTextMode eMode = pViewData->GetTextMode();
+ if( eMode == ShowTextDontKnow )
+ return eTextMode;
+ return eMode;
+}
+
+void SvImpIconView::ShowFocusRect( const SvLBoxEntry* pEntry )
+{
+ if( !pEntry )
+ pView->HideFocus();
+ else
+ {
+ Rectangle aRect ( CalcFocusRect( (SvLBoxEntry*)pEntry ) );
+ pView->ShowFocus( aRect );
+ }
+}
+
+IMPL_LINK(SvImpIconView, UserEventHdl, void*, EMPTYARG )
+{
+ nCurUserEvent = 0;
+ AdjustScrollBars();
+ Rectangle aRect;
+ if( GetResizeRect(aRect) )
+ PaintResizeRect( aRect );
+ return 0;
+}
+
+void SvImpIconView::CancelUserEvent()
+{
+ if( nCurUserEvent )
+ {
+ Application::RemoveUserEvent( nCurUserEvent );
+ nCurUserEvent = 0;
+ }
+}
+
+
diff --git a/svtools/source/contnr/svlbitm.cxx b/svtools/source/contnr/svlbitm.cxx
new file mode 100644
index 000000000000..fc6cd0c85cf8
--- /dev/null
+++ b/svtools/source/contnr/svlbitm.cxx
@@ -0,0 +1,449 @@
+/*************************************************************************
+ *
+ * $RCSfile: svlbitm.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+
+#include <svlbox.hxx>
+#include <svlbitm.hxx>
+
+#pragma hdrstop
+
+#define TABOFFS_NOT_VALID -2000000
+
+DBG_NAME(SvLBoxButtonData);
+
+SvLBoxButtonData::SvLBoxButtonData()
+{
+ DBG_CTOR(SvLBoxButtonData,0);
+ bDataOk = FALSE;
+ pEntry = 0;
+ eState = SV_BUTTON_UNCHECKED;
+}
+
+SvLBoxButtonData::~SvLBoxButtonData()
+{
+ DBG_DTOR(SvLBoxButtonData,0);
+}
+
+
+void SvLBoxButtonData::CallLink()
+{
+ DBG_CHKTHIS(SvLBoxButtonData,0);
+ aLink.Call( this );
+}
+
+
+USHORT SvLBoxButtonData::GetIndex( USHORT nItemState )
+{
+ DBG_CHKTHIS(SvLBoxButtonData,0);
+ nItemState &= 0x000F;
+ USHORT nIdx;
+ switch( nItemState )
+ {
+ case SV_ITEMSTATE_UNCHECKED:
+ nIdx = SV_BMP_UNCHECKED; break;
+ case SV_ITEMSTATE_CHECKED:
+ nIdx = SV_BMP_CHECKED; break;
+ case SV_ITEMSTATE_TRISTATE:
+ nIdx = SV_BMP_TRISTATE; break;
+ case SV_ITEMSTATE_UNCHECKED | SV_ITEMSTATE_HILIGHTED:
+ nIdx = SV_BMP_HIUNCHECKED; break;
+ case SV_ITEMSTATE_CHECKED | SV_ITEMSTATE_HILIGHTED:
+ nIdx = SV_BMP_HICHECKED; break;
+ case SV_ITEMSTATE_TRISTATE | SV_ITEMSTATE_HILIGHTED:
+ nIdx = SV_BMP_HITRISTATE; break;
+ default:
+ nIdx = SV_BMP_UNCHECKED;
+ }
+ return nIdx;
+}
+
+void SvLBoxButtonData::SetWidthAndHeight()
+{
+ DBG_CHKTHIS(SvLBoxButtonData,0);
+ Size aSize = aBmps[0].GetSizePixel();
+ nWidth = aSize.Width();
+ nHeight = aSize.Height();
+ bDataOk = TRUE;
+}
+
+
+void SvLBoxButtonData::StoreButtonState( SvLBoxEntry* pActEntry, USHORT nItemFlags )
+{
+ DBG_CHKTHIS(SvLBoxButtonData,0);
+ pEntry = pActEntry;
+ eState = ConvertToButtonState( nItemFlags );
+}
+
+SvButtonState SvLBoxButtonData::ConvertToButtonState( USHORT nItemFlags ) const
+{
+ DBG_CHKTHIS(SvLBoxButtonData,0);
+ nItemFlags &= (SV_ITEMSTATE_UNCHECKED |
+ SV_ITEMSTATE_CHECKED |
+ SV_ITEMSTATE_TRISTATE);
+ switch( nItemFlags )
+ {
+ case SV_ITEMSTATE_UNCHECKED:
+ return SV_BUTTON_UNCHECKED;
+
+ case SV_ITEMSTATE_CHECKED:
+ return SV_BUTTON_CHECKED;
+
+ case SV_ITEMSTATE_TRISTATE:
+ return SV_BUTTON_TRISTATE;
+ default:
+ return SV_BUTTON_UNCHECKED;
+ }
+}
+
+
+// ***************************************************************
+// class SvLBoxString
+// ***************************************************************
+
+DBG_NAME(SvLBoxString);
+
+SvLBoxString::SvLBoxString( SvLBoxEntry* pEntry,USHORT nFlags,const XubString& rStr) :
+ SvLBoxItem( pEntry, nFlags )
+{
+ DBG_CTOR(SvLBoxString,0);
+ SetText( pEntry, rStr );
+}
+
+SvLBoxString::SvLBoxString() : SvLBoxItem()
+{
+ DBG_CTOR(SvLBoxString,0);
+}
+
+SvLBoxString::~SvLBoxString()
+{
+ DBG_DTOR(SvLBoxString,0);
+}
+
+USHORT SvLBoxString::IsA()
+{
+ DBG_CHKTHIS(SvLBoxString,0);
+ return SV_ITEM_ID_LBOXSTRING;
+}
+
+void SvLBoxString::Paint( const Point& rPos, SvLBox& rDev, USHORT /* nFlags */,
+ SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvLBoxString,0);
+ rDev.DrawText( rPos, aStr );
+}
+
+SvLBoxItem* SvLBoxString::Create() const
+{
+ DBG_CHKTHIS(SvLBoxString,0);
+ return new SvLBoxString;
+}
+
+void SvLBoxString::Clone( SvLBoxItem* pSource )
+{
+ DBG_CHKTHIS(SvLBoxString,0);
+ aStr = ((SvLBoxString*)pSource)->aStr;
+}
+
+void SvLBoxString::SetText( SvLBoxEntry*, const XubString& rStr )
+{
+ DBG_CHKTHIS(SvLBoxString,0);
+ aStr = rStr;
+}
+
+void SvLBoxString::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+ SvViewDataItem* pViewData)
+{
+ DBG_CHKTHIS(SvLBoxString,0);
+ if( !pViewData )
+ pViewData = pView->GetViewDataItem( pEntry, this );
+ pViewData->aSize = Size(pView->GetTextWidth( aStr ), pView->GetTextHeight());
+}
+
+// ***************************************************************
+// class SvLBoxBmp
+// ***************************************************************
+
+DBG_NAME(SvLBoxBmp);
+
+SvLBoxBmp::SvLBoxBmp( SvLBoxEntry* pEntry, USHORT nFlags, Image aBitmap ) :
+ SvLBoxItem( pEntry, nFlags )
+{
+ DBG_CTOR(SvLBoxBmp,0);
+ SetBitmap( pEntry, aBitmap);
+}
+
+SvLBoxBmp::SvLBoxBmp() : SvLBoxItem()
+{
+ DBG_CTOR(SvLBoxBmp,0);
+}
+
+SvLBoxBmp::~SvLBoxBmp()
+{
+ DBG_DTOR(SvLBoxBmp,0);
+}
+
+USHORT SvLBoxBmp::IsA()
+{
+ DBG_CHKTHIS(SvLBoxBmp,0);
+ return SV_ITEM_ID_LBOXBMP;
+}
+
+void SvLBoxBmp::SetBitmap( SvLBoxEntry*, Image aBitmap)
+{
+ DBG_CHKTHIS(SvLBoxBmp,0);
+ aBmp = aBitmap;
+}
+
+void SvLBoxBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+ SvViewDataItem* pViewData)
+{
+ DBG_CHKTHIS(SvLBoxBmp,0);
+ if( !pViewData )
+ pViewData = pView->GetViewDataItem( pEntry, this );
+ pViewData->aSize = aBmp.GetSizePixel();
+}
+
+void SvLBoxBmp::Paint( const Point& rPos, SvLBox& rDev, USHORT /* nFlags */,
+ SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvLBoxBmp,0);
+ rDev.DrawImage( rPos, aBmp );
+}
+
+SvLBoxItem* SvLBoxBmp::Create() const
+{
+ DBG_CHKTHIS(SvLBoxBmp,0);
+ return new SvLBoxBmp;
+}
+
+void SvLBoxBmp::Clone( SvLBoxItem* pSource )
+{
+ DBG_CHKTHIS(SvLBoxBmp,0);
+ aBmp = ((SvLBoxBmp*)pSource)->aBmp;
+}
+
+// ***************************************************************
+// class SvLBoxButton
+// ***************************************************************
+
+DBG_NAME(SvLBoxButton);
+
+SvLBoxButton::SvLBoxButton( SvLBoxEntry* pEntry,USHORT nFlags,SvLBoxButtonData* pBData)
+ : SvLBoxItem( pEntry, nFlags )
+{
+ DBG_CTOR(SvLBoxButton,0);
+ nBaseOffs = 0;
+ nItemFlags = 0;
+ SetStateUnchecked();
+ pData = pBData;
+}
+
+SvLBoxButton::SvLBoxButton() : SvLBoxItem()
+{
+ DBG_CTOR(SvLBoxButton,0);
+ nItemFlags = 0;
+ SetStateUnchecked();
+}
+
+SvLBoxButton::~SvLBoxButton()
+{
+ DBG_DTOR(SvLBoxButton,0);
+}
+
+USHORT SvLBoxButton::IsA()
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ return SV_ITEM_ID_LBOXBUTTON;
+}
+
+void SvLBoxButton::Check(SvLBox*, SvLBoxEntry*, BOOL bOn)
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ if ( bOn != IsStateChecked() )
+ {
+ if ( bOn )
+ SetStateChecked();
+ else
+ SetStateUnchecked();
+ }
+}
+
+BOOL SvLBoxButton::ClickHdl( SvLBox*, SvLBoxEntry* pEntry )
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ if ( IsStateChecked() )
+ SetStateUnchecked();
+ else
+ SetStateChecked();
+ pData->StoreButtonState( pEntry, nItemFlags );
+ pData->CallLink();
+ return FALSE;
+}
+
+void SvLBoxButton::Paint( const Point& rPos, SvLBox& rDev, USHORT /* nFlags */,
+ SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ USHORT nIndex = pData->GetIndex( nItemFlags );
+ rDev.DrawImage( rPos, pData->aBmps[nIndex + nBaseOffs] );
+}
+
+SvLBoxItem* SvLBoxButton::Create() const
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ return new SvLBoxButton;
+}
+
+void SvLBoxButton::Clone( SvLBoxItem* pSource )
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ pData = ((SvLBoxButton*)pSource)->pData;
+}
+
+void SvLBoxButton::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+ SvViewDataItem* pViewData )
+{
+ DBG_CHKTHIS(SvLBoxButton,0);
+ if( !pViewData )
+ pViewData = pView->GetViewDataItem( pEntry, this );
+ pViewData->aSize = Size( pData->Width(), pData->Height() );
+}
+
+
+
+// ***************************************************************
+// class SvLBoxContextBmp
+// ***************************************************************
+
+DBG_NAME(SvLBoxContextBmp);
+
+SvLBoxContextBmp::SvLBoxContextBmp( SvLBoxEntry* pEntry, USHORT nItemFlags,
+ Image aBmp1, Image aBmp2, USHORT nEntryFlags )
+ : SvLBoxItem( pEntry, nItemFlags )
+{
+ DBG_CTOR(SvLBoxContextBmp,0);
+ nEntryFlagsBmp1 = nEntryFlags;
+ SetBitmap1( pEntry, aBmp1 );
+ SetBitmap2( pEntry, aBmp2 );
+}
+
+SvLBoxContextBmp::SvLBoxContextBmp()
+{
+ DBG_CTOR(SvLBoxContextBmp,0);
+}
+
+SvLBoxContextBmp::~SvLBoxContextBmp()
+{
+ DBG_DTOR(SvLBoxContextBmp,0);
+}
+
+USHORT SvLBoxContextBmp::IsA()
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ return SV_ITEM_ID_LBOXCONTEXTBMP;
+}
+
+void SvLBoxContextBmp::SetBitmap1( SvLBoxEntry*, Image aBmp )
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ aBmp1 = aBmp;
+}
+
+void SvLBoxContextBmp::SetBitmap2( SvLBoxEntry*, Image aBmp)
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ aBmp2 = aBmp;
+}
+
+void SvLBoxContextBmp::InitViewData( SvLBox* pView,SvLBoxEntry* pEntry,
+ SvViewDataItem* pViewData)
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ if( !pViewData )
+ pViewData = pView->GetViewDataItem( pEntry, this );
+ pViewData->aSize = aBmp1.GetSizePixel();
+}
+
+void SvLBoxContextBmp::Paint( const Point& rPos, SvLBox& rDev,
+ USHORT nViewDataEntryFlags, SvLBoxEntry* pEntry )
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ Image* pBmp = &aBmp1;
+ if( nViewDataEntryFlags & nEntryFlagsBmp1 )
+ pBmp = &aBmp2;
+ rDev.DrawImage( rPos, *pBmp);
+}
+
+SvLBoxItem* SvLBoxContextBmp::Create() const
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ return new SvLBoxContextBmp;
+}
+
+void SvLBoxContextBmp::Clone( SvLBoxItem* pSource )
+{
+ DBG_CHKTHIS(SvLBoxContextBmp,0);
+ aBmp1 = ((SvLBoxContextBmp*)pSource)->aBmp1;
+ aBmp2 = ((SvLBoxContextBmp*)pSource)->aBmp2;
+ nEntryFlagsBmp1 = ((SvLBoxContextBmp*)pSource)->nEntryFlagsBmp1;
+}
+
+
diff --git a/svtools/source/contnr/svlbox.cxx b/svtools/source/contnr/svlbox.cxx
new file mode 100644
index 000000000000..2d7b9b333e99
--- /dev/null
+++ b/svtools/source/contnr/svlbox.cxx
@@ -0,0 +1,1691 @@
+/*************************************************************************
+ *
+ * $RCSfile: svlbox.cxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: hr $ $Date: 2000-09-18 16:58:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/*
+ Todo:
+ - Anker loeschen in SelectionEngine bei manuellem Selektieren
+ - SelectAll( FALSE ), nur die deselektierten Entries repainten
+*/
+
+
+#include <string.h>
+#ifndef _SVEDI_HXX
+#include <svmedit.hxx>
+#endif
+#ifndef _SV_SVAPP_HXX
+#include <vcl/svapp.hxx>
+#endif
+#ifndef _SV_ACCEL_HXX
+#include <vcl/accel.hxx>
+#endif
+#ifndef _SV_DRAG_HXX
+#include <vcl/drag.hxx>
+#endif
+#ifndef _SOT_FORMATS_HXX
+#include <sot/formats.hxx>
+#endif
+
+#pragma hdrstop
+
+#include <svlbox.hxx>
+#include <svlbitm.hxx>
+
+// fuer Drag&Drop
+static SvLBox* pDDSource = 0;
+static SvLBox* pDDTarget = 0;
+
+DBG_NAME(SvInplaceEdit);
+DBG_NAME(SvInplaceEdit2);
+
+#define SVLBOX_ACC_RETURN 1
+#define SVLBOX_ACC_ESCAPE 2
+
+SvInplaceEdit::SvInplaceEdit( Window* pParent, const Point& rPos,
+ const Size& rSize, const XubString& rData, const Link& rNotifyEditEnd,
+ const Selection& rSelection) :
+#ifndef OS2
+ Edit( pParent, WB_LEFT ),
+#else
+ Edit( pParent, WB_LEFT | WB_BORDER ),
+#endif
+ aCallBackHdl( rNotifyEditEnd ),
+ bCanceled( FALSE ),
+ bAlreadyInCallBack( FALSE )
+{
+ DBG_CTOR(SvInplaceEdit,0);
+ Font aFont( pParent->GetFont() );
+ aFont.SetTransparent( FALSE );
+ Color aColor( pParent->GetBackground().GetColor() );
+ aFont.SetFillColor(aColor );
+ SetFont( aFont );
+ SetBackground( pParent->GetBackground() );
+ SetPosPixel( rPos );
+ SetSizePixel( rSize );
+ SetText( rData );
+ SetSelection( rSelection );
+ SaveValue();
+
+ aAccReturn.InsertItem( SVLBOX_ACC_RETURN, KeyCode(KEY_RETURN) );
+ aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, KeyCode(KEY_ESCAPE) );
+
+ aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit, ReturnHdl_Impl) );
+ aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit, EscapeHdl_Impl) );
+ GetpApp()->InsertAccel( &aAccReturn );
+ GetpApp()->InsertAccel( &aAccEscape );
+
+ Show();
+ GrabFocus();
+}
+
+__EXPORT SvInplaceEdit::~SvInplaceEdit()
+{
+ DBG_DTOR(SvInplaceEdit,0);
+ if( !bAlreadyInCallBack )
+ {
+ GetpApp()->RemoveAccel( &aAccReturn );
+ GetpApp()->RemoveAccel( &aAccEscape );
+ }
+}
+
+
+
+IMPL_LINK_INLINE_START( SvInplaceEdit, ReturnHdl_Impl, Accelerator *, pAccelerator )
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ bCanceled = FALSE;
+ CallCallBackHdl_Impl();
+ return 1;
+}
+IMPL_LINK_INLINE_END( SvInplaceEdit, ReturnHdl_Impl, Accelerator *, pAccelerator )
+
+IMPL_LINK_INLINE_START( SvInplaceEdit, EscapeHdl_Impl, Accelerator *, pAccelerator )
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ bCanceled = TRUE;
+ CallCallBackHdl_Impl();
+ return 1;
+}
+IMPL_LINK_INLINE_END( SvInplaceEdit, EscapeHdl_Impl, Accelerator *, pAccelerator )
+
+
+void __EXPORT SvInplaceEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ USHORT nCode = rKEvt.GetKeyCode().GetCode();
+ switch ( nCode )
+ {
+ case KEY_ESCAPE:
+ bCanceled = TRUE;
+ CallCallBackHdl_Impl();
+ break;
+
+ case KEY_RETURN:
+ bCanceled = FALSE;
+ CallCallBackHdl_Impl();
+ break;
+
+ default:
+ Edit::KeyInput( rKEvt );
+ }
+}
+
+void SvInplaceEdit::StopEditing( BOOL bCancel )
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ if ( !bAlreadyInCallBack )
+ {
+ bCanceled = bCancel;
+ CallCallBackHdl_Impl();
+ }
+}
+
+void __EXPORT SvInplaceEdit::LoseFocus()
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ if ( !bAlreadyInCallBack )
+ {
+ bCanceled = FALSE;
+ aTimer.SetTimeout(10);
+ aTimer.SetTimeoutHdl(LINK(this,SvInplaceEdit,Timeout_Impl));
+ aTimer.Start();
+ }
+}
+
+IMPL_LINK_INLINE_START( SvInplaceEdit, Timeout_Impl, Timer *, pTimer )
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ CallCallBackHdl_Impl();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvInplaceEdit, Timeout_Impl, Timer *, pTimer )
+
+void SvInplaceEdit::CallCallBackHdl_Impl()
+{
+ DBG_CHKTHIS(SvInplaceEdit,0);
+ aTimer.Stop();
+ if ( !bAlreadyInCallBack )
+ {
+ bAlreadyInCallBack = TRUE;
+ GetpApp()->RemoveAccel( &aAccReturn );
+ GetpApp()->RemoveAccel( &aAccEscape );
+ Hide();
+ aCallBackHdl.Call( this );
+ // bAlreadyInCallBack = FALSE;
+ }
+}
+
+
+// ***************************************************************
+
+class MyEdit_Impl : public Edit
+{
+ SvInplaceEdit2* pOwner;
+public:
+ MyEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void LoseFocus();
+};
+
+class MyMultiEdit_Impl : public MultiLineEdit
+{
+ SvInplaceEdit2* pOwner;
+public:
+ MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* pOwner );
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual void LoseFocus();
+};
+
+MyEdit_Impl::MyEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner )
+ :
+#ifndef OS2
+ Edit( pParent, WB_LEFT ),
+#else
+ Edit( pParent, WB_LEFT | WB_BORDER ),
+#endif
+ pOwner(_pOwner)
+{
+}
+
+void MyEdit_Impl::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !pOwner->KeyInput( rKEvt ))
+ Edit::KeyInput( rKEvt );
+}
+
+void MyEdit_Impl::LoseFocus()
+{
+ pOwner->LoseFocus();
+}
+
+MyMultiEdit_Impl::MyMultiEdit_Impl( Window* pParent, SvInplaceEdit2* _pOwner )
+ : MultiLineEdit( pParent,
+#if !defined(VCL)
+#if defined(WIN) || defined(WNT)
+ WB_CENTER
+#else
+ WB_LEFT
+#endif
+#else
+ WB_CENTER
+#endif
+ ), pOwner(_pOwner)
+{
+}
+
+void MyMultiEdit_Impl::KeyInput( const KeyEvent& rKEvt )
+{
+ if( !pOwner->KeyInput( rKEvt ))
+ MultiLineEdit::KeyInput( rKEvt );
+}
+
+void MyMultiEdit_Impl::LoseFocus()
+{
+ pOwner->LoseFocus();
+}
+
+
+SvInplaceEdit2::SvInplaceEdit2( Window* pParent, const Point& rPos,
+ const Size& rSize, const XubString& rData, const Link& rNotifyEditEnd,
+ const Selection& rSelection, BOOL bMulti) :
+ aCallBackHdl( rNotifyEditEnd ),
+ bCanceled( FALSE ),
+ bAlreadyInCallBack( FALSE ),
+ bMultiLine( bMulti )
+{
+ DBG_CTOR(SvInplaceEdit2,0);
+ if( bMulti )
+ pEdit = new MyMultiEdit_Impl( pParent, this );
+ else
+ pEdit = new MyEdit_Impl( pParent, this );
+
+ Font aFont( pParent->GetFont() );
+ aFont.SetTransparent( FALSE );
+ Color aColor( pParent->GetBackground().GetColor() );
+ aFont.SetFillColor(aColor );
+ pEdit->SetFont( aFont );
+ pEdit->SetBackground( pParent->GetBackground() );
+ pEdit->SetPosPixel( rPos );
+ pEdit->SetSizePixel( rSize );
+ pEdit->SetText( rData );
+#ifndef OS2
+ pEdit->SetSelection( rSelection );
+#else
+ if( !bMulti )
+ pEdit->SetSelection( rSelection );
+#endif
+ pEdit->SaveValue();
+
+ aAccReturn.InsertItem( SVLBOX_ACC_RETURN, KeyCode(KEY_RETURN) );
+ aAccEscape.InsertItem( SVLBOX_ACC_ESCAPE, KeyCode(KEY_ESCAPE) );
+
+ aAccReturn.SetActivateHdl( LINK( this, SvInplaceEdit2, ReturnHdl_Impl) );
+ aAccEscape.SetActivateHdl( LINK( this, SvInplaceEdit2, EscapeHdl_Impl) );
+ GetpApp()->InsertAccel( &aAccReturn );
+ GetpApp()->InsertAccel( &aAccEscape );
+
+ pEdit->Show();
+ pEdit->GrabFocus();
+}
+
+SvInplaceEdit2::~SvInplaceEdit2()
+{
+ DBG_DTOR(SvInplaceEdit2,0);
+ if( !bAlreadyInCallBack )
+ {
+ GetpApp()->RemoveAccel( &aAccReturn );
+ GetpApp()->RemoveAccel( &aAccEscape );
+ }
+ delete pEdit;
+}
+
+XubString SvInplaceEdit2::GetSavedValue() const
+{
+ return pEdit->GetSavedValue();
+}
+
+void SvInplaceEdit2::Hide()
+{
+ pEdit->Hide();
+}
+
+
+IMPL_LINK_INLINE_START( SvInplaceEdit2, ReturnHdl_Impl, Accelerator *, pAccelerator )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ bCanceled = FALSE;
+ CallCallBackHdl_Impl();
+ return 1;
+}
+IMPL_LINK_INLINE_END( SvInplaceEdit2, ReturnHdl_Impl, Accelerator *, pAccelerator )
+
+IMPL_LINK_INLINE_START( SvInplaceEdit2, EscapeHdl_Impl, Accelerator *, pAccelerator )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ bCanceled = TRUE;
+ CallCallBackHdl_Impl();
+ return 1;
+}
+IMPL_LINK_INLINE_END( SvInplaceEdit2, EscapeHdl_Impl, Accelerator *, pAccelerator )
+
+
+BOOL SvInplaceEdit2::KeyInput( const KeyEvent& rKEvt )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ KeyCode aCode = rKEvt.GetKeyCode();
+ USHORT nCode = aCode.GetCode();
+
+ switch ( nCode )
+ {
+ case KEY_ESCAPE:
+ bCanceled = TRUE;
+ CallCallBackHdl_Impl();
+ return TRUE;
+
+ case KEY_RETURN:
+// if( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
+ {
+ bCanceled = FALSE;
+ CallCallBackHdl_Impl();
+ return TRUE;
+ }
+ break;
+ }
+ return FALSE;
+}
+
+void SvInplaceEdit2::StopEditing( BOOL bCancel )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ if ( !bAlreadyInCallBack )
+ {
+ bCanceled = bCancel;
+ CallCallBackHdl_Impl();
+ }
+}
+
+void SvInplaceEdit2::LoseFocus()
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ if ( !bAlreadyInCallBack
+#ifdef VCL
+ && ((!Application::GetFocusWindow()) || !pEdit->IsChild( Application::GetFocusWindow()) )
+#endif
+ )
+ {
+ bCanceled = FALSE;
+ aTimer.SetTimeout(10);
+ aTimer.SetTimeoutHdl(LINK(this,SvInplaceEdit2,Timeout_Impl));
+ aTimer.Start();
+ }
+}
+
+IMPL_LINK_INLINE_START( SvInplaceEdit2, Timeout_Impl, Timer *, pTimer )
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ CallCallBackHdl_Impl();
+ return 0;
+}
+IMPL_LINK_INLINE_END( SvInplaceEdit2, Timeout_Impl, Timer *, pTimer )
+
+void SvInplaceEdit2::CallCallBackHdl_Impl()
+{
+ DBG_CHKTHIS(SvInplaceEdit2,0);
+ aTimer.Stop();
+ if ( !bAlreadyInCallBack )
+ {
+ bAlreadyInCallBack = TRUE;
+ GetpApp()->RemoveAccel( &aAccReturn );
+ GetpApp()->RemoveAccel( &aAccEscape );
+ pEdit->Hide();
+ aCallBackHdl.Call( this );
+ }
+}
+
+XubString SvInplaceEdit2::GetText() const
+{
+ return pEdit->GetText();
+}
+
+// ***************************************************************
+// class SvLBoxTab
+// ***************************************************************
+
+DBG_NAME(SvLBoxTab);
+
+SvLBoxTab::SvLBoxTab()
+{
+ DBG_CTOR(SvLBoxTab,0);
+ nPos = 0;
+ pUserData = 0;
+ nFlags = 0;
+}
+
+SvLBoxTab::SvLBoxTab( long nPosition, USHORT nTabFlags )
+{
+ DBG_CTOR(SvLBoxTab,0);
+ nPos = nPosition;
+ pUserData = 0;
+ nFlags = nTabFlags;
+}
+
+SvLBoxTab::SvLBoxTab( const SvLBoxTab& rTab )
+{
+ DBG_CTOR(SvLBoxTab,0);
+ nPos = rTab.nPos;
+ pUserData = rTab.pUserData;
+ nFlags = rTab.nFlags;
+}
+
+SvLBoxTab::~SvLBoxTab()
+{
+ DBG_DTOR(SvLBoxTab,0);
+}
+
+
+long SvLBoxTab::CalcOffset( long nItemWidth, long nTabWidth )
+{
+ DBG_CHKTHIS(SvLBoxTab,0);
+ long nOffset = 0;
+ if ( nFlags & SV_LBOXTAB_ADJUST_RIGHT )
+ {
+ nOffset = nTabWidth - nItemWidth;
+ if( nOffset < 0 )
+ nOffset = 0;
+ }
+ else if ( nFlags & SV_LBOXTAB_ADJUST_CENTER )
+ {
+ if( nFlags & SV_LBOXTAB_FORCE )
+ {
+ //richtige Implementierung der Zentrierung
+ nOffset = ( nTabWidth - nItemWidth ) / 2;
+ if( nOffset < 0 )
+ nOffset = 0;
+ }
+ else
+ {
+ // historisch gewachsene falsche Berechnung des Tabs, auf die sich
+ // Abo-Tabbox, Extras/Optionen/Anpassen etc. verlassen
+ nItemWidth++;
+ nOffset = -( nItemWidth / 2 );
+ }
+ }
+ return nOffset;
+}
+
+/*
+long SvLBoxTab::CalcOffset( const XubString& rStr, const OutputDevice& rOutDev )
+{
+ DBG_CHKTHIS(SvLBoxTab,0);
+ long nWidth;
+ if ( nFlags & SV_LBOXTAB_ADJUST_NUMERIC )
+ {
+ USHORT nPos = rStr.Search( '.' );
+ if ( nPos == STRING_NOTFOUND )
+ nPos = rStr.Search( ',' );
+ if ( nPos == STRING_NOTFOUND )
+ nPos = STRING_LEN;
+
+ nWidth = rOutDev.GetTextSize( rStr, 0, nPos ).Width();
+ nWidth *= -1;
+ }
+ else
+ {
+ nWidth = rOutDev.GetTextSize( rStr ).Width();
+ nWidth = CalcOffset( nWidth );
+ }
+ return nWidth;
+}
+*/
+
+// ***************************************************************
+// class SvLBoxItem
+// ***************************************************************
+
+DBG_NAME(SvLBoxItem);
+
+SvLBoxItem::SvLBoxItem( SvLBoxEntry*, USHORT )
+{
+ DBG_CTOR(SvLBoxItem,0);
+}
+
+SvLBoxItem::SvLBoxItem()
+{
+ DBG_CTOR(SvLBoxItem,0);
+}
+
+SvLBoxItem::~SvLBoxItem()
+{
+ DBG_DTOR(SvLBoxItem,0);
+}
+
+const Size& SvLBoxItem::GetSize( SvLBox* pView,SvLBoxEntry* pEntry )
+{
+ DBG_CHKTHIS(SvLBoxItem,0);
+ SvViewDataItem* pViewData = pView->GetViewDataItem( pEntry, this );
+ return pViewData->aSize;
+}
+
+const Size& SvLBoxItem::GetSize( SvLBoxEntry* pEntry, SvViewDataEntry* pViewData)
+{
+ DBG_CHKTHIS(SvLBoxItem,0);
+ USHORT nItemPos = pEntry->GetPos( this );
+ SvViewDataItem* pItemData = pViewData->pItemData+nItemPos;
+ return pItemData->aSize;
+}
+
+DBG_NAME(SvViewDataItem);
+
+SvViewDataItem::SvViewDataItem()
+{
+ DBG_CTOR(SvViewDataItem,0);
+}
+
+SvViewDataItem::~SvViewDataItem()
+{
+ DBG_DTOR(SvViewDataItem,0);
+}
+
+
+
+// ***************************************************************
+// class SvLBoxEntry
+// ***************************************************************
+
+DBG_NAME(SvLBoxEntry);
+
+SvLBoxEntry::SvLBoxEntry() : aItems()
+{
+ DBG_CTOR(SvLBoxEntry,0);
+ nEntryFlags = 0;
+ pUserData = 0;
+}
+
+SvLBoxEntry::~SvLBoxEntry()
+{
+ DBG_DTOR(SvLBoxEntry,0);
+ DeleteItems_Impl();
+}
+
+void SvLBoxEntry::DeleteItems_Impl()
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ USHORT nCount = aItems.Count();
+ while( nCount )
+ {
+ nCount--;
+ SvLBoxItem* pItem = (SvLBoxItem*)aItems.GetObject( nCount );
+ delete pItem;
+ }
+ aItems.Remove(0, aItems.Count() );
+}
+
+
+void SvLBoxEntry::AddItem( SvLBoxItem* pItem )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ aItems.Insert( pItem, aItems.Count() );
+}
+
+void SvLBoxEntry::Clone( SvListEntry* pSource )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ SvListEntry::Clone( pSource );
+ SvLBoxItem* pNewItem;
+ DeleteItems_Impl();
+ USHORT nCount = ((SvLBoxEntry*)pSource)->ItemCount();
+ USHORT nCurPos = 0;
+ while( nCurPos < nCount )
+ {
+ SvLBoxItem* pItem = ((SvLBoxEntry*)pSource)->GetItem( nCurPos );
+ pNewItem = pItem->Create();
+ pNewItem->Clone( pItem );
+ AddItem( pNewItem );
+ nCurPos++;
+ }
+ pUserData = ((SvLBoxEntry*)pSource)->GetUserData();
+ nEntryFlags = ((SvLBoxEntry*)pSource)->nEntryFlags;
+}
+
+void SvLBoxEntry::EnableChildsOnDemand( BOOL bEnable )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ if ( bEnable )
+ nEntryFlags |= SV_ENTRYFLAG_CHILDS_ON_DEMAND;
+ else
+ nEntryFlags &= (~SV_ENTRYFLAG_CHILDS_ON_DEMAND);
+}
+
+void SvLBoxEntry::ReplaceItem( SvLBoxItem* pNewItem, USHORT nPos )
+{
+ DBG_CHKTHIS(SvLBoxEntry,0);
+ DBG_ASSERT(pNewItem,"ReplaceItem:No Item")
+ SvLBoxItem* pOld = GetItem( nPos );
+ if ( pOld )
+ {
+ aItems.Remove( nPos );
+ aItems.Insert( pNewItem, nPos );
+ delete pOld;
+ }
+}
+
+SvLBoxItem* SvLBoxEntry::GetFirstItem( USHORT nId )
+{
+ USHORT nCount = aItems.Count();
+ USHORT nCur = 0;
+ SvLBoxItem* pItem;
+ while( nCur < nCount )
+ {
+ pItem = GetItem( nCur );
+ if( pItem->IsA() == nId )
+ return pItem;
+ nCur++;
+ }
+ return 0;
+}
+
+// ***************************************************************
+// class SvLBoxViewData
+// ***************************************************************
+
+DBG_NAME(SvViewDataEntry);
+
+SvViewDataEntry::SvViewDataEntry()
+ : SvViewData()
+{
+ DBG_CTOR(SvViewDataEntry,0);
+ pItemData = 0;
+}
+
+SvViewDataEntry::~SvViewDataEntry()
+{
+ DBG_DTOR(SvViewDataEntry,0);
+ __DELETE(nItmCnt) pItemData;
+}
+
+// ***************************************************************
+// class SvLBox
+// ***************************************************************
+
+DBG_NAME(SvLBox);
+
+
+__EXPORT SvLBox::SvLBox( Window* pParent, WinBits nWinStyle ) :
+ Control( pParent, nWinStyle | WB_CLIPCHILDREN )
+{
+ DBG_CTOR(SvLBox,0);
+ nWindowStyle = nWinStyle;
+ nDragOptions = DRAG_ALL;
+ nImpFlags = 0;
+ pTargetEntry = 0;
+ nDragDropMode = 0;
+ pReserved = 0;
+ nReserved = 0;
+ SvLBoxTreeList* pTempModel = new SvLBoxTreeList;
+ pTempModel->SetRefCount( 0 );
+ SetModel( pTempModel );
+ pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
+ pModel->InsertView( this );
+ pHdlEntry = 0;
+ pEdCtrl = 0;
+ aMovePtr = Pointer( POINTER_MOVEDATA );
+ aCopyPtr = Pointer( POINTER_COPYDATA );
+ SetSelectionMode( SINGLE_SELECTION ); // pruefen ob TreeListBox gecallt wird
+ SetDragDropMode( SV_DRAGDROP_NONE );
+#ifdef MAC
+ Font aFont( "Geneva", Size( 0, 10 ) );
+ SetFont( aFont );
+#endif
+}
+
+__EXPORT SvLBox::SvLBox( Window* pParent, const ResId& rResId ) :
+ Control( pParent, rResId )
+{
+ DBG_CTOR(SvLBox,0);
+ pTargetEntry = 0;
+ nImpFlags = 0;
+ nWindowStyle = 0;
+ pReserved = 0;
+ nReserved = 0;
+ nDragOptions = DRAG_ALL;
+ nDragDropMode = 0;
+ SvLBoxTreeList* pTempModel = new SvLBoxTreeList;
+ pTempModel->SetRefCount( 0 );
+ SetModel( pTempModel );
+ pModel->InsertView( this );
+ pHdlEntry = 0;
+ pEdCtrl = 0;
+ pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
+ aMovePtr = Pointer( POINTER_MOVEDATA );
+ aCopyPtr = Pointer( POINTER_COPYDATA );
+#ifdef MAC
+ Font aFont( "Geneva", Size( 0, 10 ) );
+ SetFont( aFont );
+#endif
+}
+
+
+__EXPORT SvLBox::~SvLBox()
+{
+ DBG_DTOR(SvLBox,0);
+ delete pEdCtrl;
+ pEdCtrl = 0;
+ pModel->RemoveView( this );
+ if ( pModel->GetRefCount() == 0 )
+ {
+ pModel->Clear();
+ delete pModel;
+ }
+ if( nReserved )
+ {
+ *((BOOL*)nReserved) = TRUE;
+ }
+}
+
+void SvLBox::SetModel( SvLBoxTreeList* pNewModel )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ // erledigt das ganz CleanUp
+ SvListView::SetModel( pNewModel );
+ pModel->SetCloneLink( LINK(this, SvLBox, CloneHdl_Impl ));
+ SvLBoxEntry* pEntry = First();
+ while( pEntry )
+ {
+ ModelHasInserted( pEntry );
+ pEntry = Next( pEntry );
+ }
+}
+
+void SvLBox::DisconnectFromModel()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ SvLBoxTreeList* pNewModel = new SvLBoxTreeList;
+ SvListView::SetModel( pNewModel );
+}
+
+void SvLBox::Clear()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ pModel->Clear(); // Model ruft SvLBox::ModelHasCleared() auf
+}
+
+
+USHORT SvLBox::IsA()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ return SVLISTBOX_ID_LBOX;
+}
+
+IMPL_LINK_INLINE_START( SvLBox, CloneHdl_Impl, SvListEntry*, pEntry )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ return (long)(CloneEntry((SvLBoxEntry*)pEntry));
+}
+IMPL_LINK_INLINE_END( SvLBox, CloneHdl_Impl, SvListEntry*, pEntry )
+
+ULONG SvLBox::Insert( SvLBoxEntry* pEntry, SvLBoxEntry* pParent, ULONG nPos )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ ULONG nInsPos = pModel->Insert( pEntry, pParent, nPos );
+ return nInsPos;
+}
+
+ULONG SvLBox::Insert( SvLBoxEntry* pEntry,ULONG nRootPos )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ ULONG nInsPos = pModel->Insert( pEntry, nRootPos );
+ return nInsPos;
+}
+
+long SvLBox::ExpandingHdl()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ return aExpandingHdl.IsSet() ? aExpandingHdl.Call( this ) : 1;
+}
+
+void SvLBox::ExpandedHdl()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ aExpandedHdl.Call( this );
+}
+
+void SvLBox::SelectHdl()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ aSelectHdl.Call( this );
+}
+
+void SvLBox::DeselectHdl()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ aDeselectHdl.Call( this );
+}
+
+BOOL SvLBox::DoubleClickHdl()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ aDoubleClickHdl.Call( this );
+ return TRUE;
+}
+
+void __EXPORT SvLBox::BeginDrag( const Point& rPos )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ BOOL bDeleted = FALSE;
+
+ ReleaseMouse();
+ SvLBoxDDInfo aDDInfo;
+ SvLBoxEntry* pEntry = GetEntry( rPos ); // GetDropTarget( rPos );
+ if ( !pEntry )
+ {
+ EndDrag();
+ return;
+ }
+
+ DragServer::Clear();
+
+ DragDropMode nTemp = GetDragDropMode();
+ nDragDropMode = NotifyBeginDrag(pEntry);
+ if( !nDragDropMode || GetSelectionCount() == 0 )
+ {
+ nDragDropMode = nTemp;
+ EndDrag();
+ return;
+ }
+
+ ULONG nDDFormatId = SOT_FORMATSTR_ID_TREELISTBOX;
+ memset(&aDDInfo,0,sizeof(SvLBoxDDInfo));
+ aDDInfo.pApp = GetpApp();
+ aDDInfo.pSource = this;
+ aDDInfo.pDDStartEntry = pEntry;
+ // abgeleitete Views zum Zuge kommen lassen
+ WriteDragServerInfo( rPos, &aDDInfo );
+ DragServer::CopyData( &aDDInfo, sizeof(SvLBoxDDInfo), nDDFormatId );
+ pDDSource = this;
+ pDDTarget = 0;
+ DropAction eAction;
+
+ BOOL bOldUpdateMode = Control::IsUpdateMode();
+ Control::SetUpdateMode( TRUE );
+ Update();
+ Control::SetUpdateMode( bOldUpdateMode );
+
+ // Selektion & deren Childs im Model als DropTargets sperren
+ // Wichtig: Wenn im DropHandler die Selektion der
+ // SourceListBox veraendert wird, muessen vorher die Eintraege
+ // als DropTargets wieder freigeschaltet werden:
+ // (GetSourceListBox()->EnableSelectionAsDropTarget( TRUE, TRUE );)
+ EnableSelectionAsDropTarget( FALSE, TRUE /* with Childs */ );
+
+ Region aRegion( GetDragRegion() ); // fuer die Mac-Leute
+ nReserved = (ULONG)&bDeleted;
+ eAction = ExecuteDrag( aMovePtr, aCopyPtr, nDragOptions, &aRegion );
+ nReserved = 0;
+ if( bDeleted )
+ {
+ EndDrag();
+ return;
+ }
+
+ EnableSelectionAsDropTarget( TRUE, TRUE );
+
+ if( (eAction == DROP_MOVE) &&
+ (
+ (pDDTarget && ((ULONG)(pDDTarget->GetModel())!=(ULONG)(this->GetModel()))) ||
+ !pDDTarget ))
+ {
+ RemoveSelection();
+ }
+
+ ImplShowTargetEmphasis( pTargetEntry, FALSE );
+ EndDrag();
+ nDragDropMode = nTemp;
+}
+
+
+void SvLBox::EndDrag()
+{
+ DBG_CHKTHIS(SvLBox,0);
+ pDDSource = 0;
+ pDDTarget = 0;
+ pTargetEntry = 0;
+}
+
+BOOL SvLBox::CheckDragAndDropMode( SvLBox* pSource, DropAction eAction )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ if ( pSource == this )
+ {
+ if ( !(nDragDropMode & (SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY) ) )
+ return FALSE; // D&D innerhalb der Liste gesperrt
+ if ( eAction == DROP_MOVE )
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_CTRL_MOVE) )
+ return FALSE; // kein lokales Move
+ }
+ else
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_CTRL_COPY))
+ return FALSE; // kein lokales Copy
+ }
+ }
+ else
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_APP_DROP ) )
+ return FALSE; // kein Drop
+ if ( eAction == DROP_MOVE )
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_APP_MOVE) )
+ return FALSE; // kein globales Move
+ }
+ else
+ {
+ if ( !(nDragDropMode & SV_DRAGDROP_APP_COPY))
+ return FALSE; // kein globales Copy
+ }
+ }
+ return TRUE;
+}
+
+
+BOOL __EXPORT SvLBox::QueryDrop( DropEvent& rDEvt )
+{
+ DBG_CHKTHIS(SvLBox,0);
+
+ if ( rDEvt.IsLeaveWindow() || !CheckDragAndDropMode( pDDSource, rDEvt.GetAction() ) )
+ {
+ ImplShowTargetEmphasis( pTargetEntry, FALSE );
+ return FALSE;
+ }
+
+ if ( !nDragDropMode )
+ {
+ DBG_ERRORFILE( "SvLBox::QueryDrop(): no target" );
+ return FALSE;
+ }
+
+ BOOL bAllowDrop = TRUE;
+
+ ULONG nDDFormatId = SOT_FORMATSTR_ID_TREELISTBOX;
+ if ( !DragServer::HasFormat( 0, nDDFormatId ) )
+ {
+ DBG_ERRORFILE( "SvLBox::QueryDrop(): no format" );
+ bAllowDrop = FALSE;
+ }
+
+ SvLBoxEntry* pEntry = GetDropTarget( rDEvt.GetPosPixel() );
+
+ if ( bAllowDrop )
+ {
+ DBG_ASSERT( pDDSource, "SvLBox::QueryDrop(): SourceBox == 0 (__EXPORT?)" );
+ if ( pEntry && pDDSource->GetModel() == this->GetModel()
+ && rDEvt.GetAction()==DROP_MOVE
+ && ( pEntry->nEntryFlags & SV_ENTRYFLAG_DISABLE_DROP ) )
+ {
+ bAllowDrop = FALSE; // nicht auf sich selbst moven
+ }
+ }
+ if ( bAllowDrop )
+ bAllowDrop = NotifyQueryDrop( pEntry );
+
+
+ // **** Emphasis zeichnen ****
+
+ if ( bAllowDrop )
+ {
+ if ( pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS) )
+ {
+ ImplShowTargetEmphasis( pTargetEntry, FALSE );
+ pTargetEntry = pEntry;
+ ImplShowTargetEmphasis( pTargetEntry, TRUE );
+ }
+ }
+ else
+ ImplShowTargetEmphasis( pTargetEntry, FALSE );
+
+ return bAllowDrop;
+}
+
+BOOL __EXPORT SvLBox::Drop( const DropEvent& rDEvt )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ GetSourceView()->EnableSelectionAsDropTarget( TRUE, TRUE );
+
+ ImplShowTargetEmphasis( pTargetEntry, FALSE );
+ pDDTarget = this;
+ ULONG nDDFormatId = SOT_FORMATSTR_ID_TREELISTBOX;
+
+ SvLBoxDDInfo aDDInfo;
+ if( !DragServer::PasteData(0, &aDDInfo, sizeof(SvLBoxDDInfo),nDDFormatId ))
+ return FALSE;
+ ReadDragServerInfo( rDEvt.GetPosPixel(), &aDDInfo );
+
+ SvLBoxEntry* pTarget = pTargetEntry; // !!! kann 0 sein !!!
+ BOOL bDataAccepted;
+ if ( rDEvt.GetAction() == DROP_COPY )
+ bDataAccepted = CopySelection( aDDInfo.pSource, pTarget );
+ else
+ bDataAccepted = MoveSelection( aDDInfo.pSource, pTarget );
+ return bDataAccepted;
+}
+
+DragDropMode SvLBox::NotifyBeginDrag( SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ return (DragDropMode)0xffff;
+}
+
+BOOL SvLBox::NotifyQueryDrop( SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvLBox,0);
+ return TRUE;
+}
+
+void SvLBox::NotifyRemoving( SvLBoxEntry* )
+{
+ DBG_CHKTHIS(SvLBox,0);
+}
+
+/*