/***************************************************************************
                            KListView.java -  description
                             -------------------
    begin                : Sun Jan 27 16:22:17 2002
    copyright            : (C) 2000-2001 Lost Highway Ltd.
    email                : Richard_Dale@tipitina.demon.co.uk
    generated by         : duke@tipitina on Sun Jan 27 16:22:17 2002, using kalyptus 0.9.
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
***************************************************************************/

package org.kde.koala;

import org.kde.qt.*;
import java.util.*;
import java.lang.Error;

/**

 This Widget extends the functionality of QListView to honor the system
 wide settings for Single Click/Double Click mode, AutoSelection and
 ChangeCursorOverLink (TM).

 There is a new signal executed(). It gets connected to either
 {@link QListView#clicked} or  {@link QListView#doubleClicked} depending on the KDE
 wide Single Click/Double Click settings. It is strongly recommended that
 you use this signal instead of the above mentioned. This way you donīt
 need to care about the current settings.
 If you want to get informed when the user selects something connect to the
 QListView.selectionChanged() signal.

 Drag-and-Drop is supported with the signal {@link #dropped}, just {@link #setAcceptDrops}(true)
 and connect it to a suitable slot.
 To see where you are dropping, {@link #setDropVisualizer}.
 And also you'll need {@link #acceptDrag}

 KListView is drag-enabled, too: to benefit from that you've got derive from it.
 Reimplement {@link #dragObject} and (possibly) {@link #startDrag},
 and {@link #setDragEnabled}.

 See {@link KListViewSignals} for signals emitted by KListView.

 See {@link KListViewEventHandling} for event handlers to override in subclasses of KListView.

 @version $Id: KListView.java,v 1.5 2002/01/31 04:48:58 rdale Exp $
 
 @short 
 This Widget extends the functionality of QListView to honor the system
 wide settings for Single Click/Double Click mode, AutoSelection and
 ChangeCursorOverLink (TM).
*/
public class KListView extends QListView  {
	protected KListView(Class dummy){super((Class) null);}

	private native void newKListView( QWidget parent, String name);

/** 
 Constructor.

 The parameters <code>parent</code> and <code>name</code> are handled by
 {@link QListView}, as usual.
   
*/
	public KListView( QWidget parent, String name) {
		super((Class) null);
		newKListView( parent, name);
	}
	private native void newKListView();
	public KListView() {
		super((Class) null);
		newKListView();
	}

/** 
 Destructor.
   
*/
	protected native void finalize() throws InternalError;
	public native void dispose();
	public native boolean isDisposed();

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	public native void setAcceptDrops( boolean arg1);

/** 
 This function determines whether the given coordinates are within the
 execute area. The execute area is the part of a {@link QListViewItem} where mouse
 clicks or double clicks respectively generate a {@link #executed} signal.
 Depending on {@link QListView#allColumnsShowFocus} this is either the
 whole item or only the first column.

*/
	public native boolean isExecuteArea( QPoint point);

/** 
 Same thing, but from an x coordinate only. This only checks if x is in
 the first column (if all columns don't show focus), without testing if
 the y coordinate is over an item or not.
   
*/
	public native boolean isExecuteArea( int x);

/** 

*/
//	public native QPtrList<QListViewItem> selectedItems();

/** 
 Arbitrarily move <code>item</code> to <code>parent</code>, positioned immediately after item <code>after.</code>
   
*/
	public native void moveItem( QListViewItem item, QListViewItem parent, QListViewItem after);

/** 

*/
	public native QListViewItem lastItem();

/** 

*/
	public native QListViewItem lastChild();

/** 

*/
	public native boolean itemsMovable();

/** 

*/
	public native boolean itemsRenameable();

/** 

*/
	public native boolean dragEnabled();

/** 

*/
	public native boolean autoOpen();

/** 

*/
	public native boolean isRenameable( int column);

/** 

*/
	public native boolean dropVisualizer();

/** 

*/
	public native int tooltipColumn();

/** 
 For future expansions.

 Do not use.

   
*/
	public native boolean createChildren();

/** 

*/
	public native boolean dropHighlighter();

/** 
 The dropVisualizerWidth defaults to 4.

*/
	public native int dropVisualizerWidth();

/** 

*/
	public native int selectionModeExt();

/** 
 Returns the index of <code>item</code> within the item tree or -1 if
 <code>item</code> doesn't exist in this list view. This function takes
 all items into account not only the visible ones.
   
*/
	public native int itemIndex( QListViewItem item);

/** 
 Returns the item of <code>index</code> within the item tree or 0 if
 <code>index</code> doesn't exist in this list view. This function takes
 all items into account not only the visible ones.
   
*/
	public native QListViewItem itemAtIndex( int index);

/** 

   
*/
	public native void setFullWidth();

/** 
 Let the last column fit exactly all the available width.
   
*/
	public native void setFullWidth( boolean fullWidth);

/** 
 Returns whether the last column is set to fit the available width.
   
*/
	public native boolean fullWidth();

/** 
 sets the alternate background background color.
 This only has an effect if the items are KListViewItems

*/
	public native void setAlternateBackground( QColor c);

/** 

*/
	public native QColor alternateBackground();

/** 
 Saves the list view's layout (column widtsh, column order, sort column)
 to a KConfig group

*/
	public native void saveLayout( KConfig config, String group);

/** 
 Reads the list view's layout from a KConfig group as stored with
 {@link saveLayout}

*/
	public native void restoreLayout( KConfig config, String group);

/** 
 Reimplemented to remember the current sort column and order
   
*/
	public native void setSorting( int column, boolean ascending);
	public native void setSorting( int column);

/** 
 Rename column <code>c</code> of <code>item.</code>
   
*/
	public native void rename( QListViewItem item, int c);

/** 
 By default, if you called setItemsRenameable(true),
 only the first column is renameable.
 Use this function to enable the feature on other columns.

 If you want more intelligent (dynamic) selection,
 you'll have to derive from KListView,
 and override {@link #rename} and call only call it
 if you want the item to be renamed.

*/
	public native void setRenameable( int column, boolean yesno);
	public native void setRenameable( int column);

/** 
 Set whether items in the list view can be moved.
 It is enabled by default.

*/
	public native void setItemsMovable( boolean b);

/** 
 Enables inplace-renaming of items.
 It is disabled by default.

*/
	public native void setItemsRenameable( boolean b);

/** 
 Enable/Disable the dragging of items.
 It is disabled by default.
   
*/
	public native void setDragEnabled( boolean b);

/** 
 Enable/Disable AutoOpen (not implemented currently).
   
*/
	public native void setAutoOpen( boolean b);

/** 
 Enable/Disable the drawing of a drop-visualizer
 (a bar that shows where a dropped item would be inserted).
 It is enabled by default, if dragging is enabled
   
*/
	public native void setDropVisualizer( boolean b);

/** 
 Set the width of the (default) drop-visualizer.
 If you don't call this method, the width is set to 4.
   
*/
	public native void setDropVisualizerWidth( int w);

/** 
 Set which column should be used for automatic tooltips.

*/
	public native void setTooltipColumn( int column);

/** 
 Enable/Disable the drawing of a drop-highlighter
 (a rectangle around the item under the mouse cursor).
 It is disabled by default.
   
*/
	public native void setDropHighlighter( boolean b);

/** 
 For future expansions.

 Do not use.

   
*/
	public native void setCreateChildren( boolean b);

/** 
 Set the selection mode.

 A different name was chosen to avoid API-clashes with {@link QListView#setSelectionMode}.
   
*/
	public native void setSelectionModeExt( int mode);

/** 
 Determine whether a drop on position <code>p</code> would count as
 being above or below the QRect <code>rect.</code>

*/
//	protected native boolean below( QRect rect, QPoint p);

/** 
 An overloaded version of below(const QRect&, const QPoint&).

 It differs from the above only in what arguments it takes.

*/
//	protected native boolean below( QListViewItem i, QPoint p);

/** 
 Reimplemented to reload the alternate background in palette changes.

   
*/
	public native boolean event( QEvent arg1);

/** 
 Emit signal {@link executed}.

   
*/
	protected native void emitExecute( QListViewItem item, QPoint pos, int c);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void focusInEvent( QFocusEvent fe);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void focusOutEvent( QFocusEvent fe);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void leaveEvent( QEvent e);

/** 

*/
	protected native String tooltip( QListViewItem item, int column);

/** 

*/
	protected native boolean showTooltip( QListViewItem item, QPoint pos, int column);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsDragMoveEvent( QDragMoveEvent event);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsMousePressEvent( QMouseEvent e);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsMouseMoveEvent( QMouseEvent e);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsMouseDoubleClickEvent( QMouseEvent e);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsDragLeaveEvent( QDragLeaveEvent event);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsMouseReleaseEvent( QMouseEvent arg1);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsDropEvent( QDropEvent arg1);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void contentsDragEnterEvent( QDragEnterEvent arg1);

/** 

*/
	protected native QDragObject dragObject();

/** 

*/
	protected native boolean acceptDrag( QDropEvent event);

/** 
 Paint the drag line. If painter is null, don't try to :)

 If after == 0 then the marker should be drawn at the top.

*/
	protected native QRect drawDropVisualizer( QPainter p, QListViewItem parent, QListViewItem after);

/** 
 Paint the drag rectangle. If painter is null, don't try to :)

*/
	protected native QRect drawItemHighlighter( QPainter painter, QListViewItem item);

/** 
 This method calls {@link #dragObject} and starts the drag.

 Reimplement it to do fancy stuff like setting a pixmap or
 using a non-default DragMode
   
*/
	protected native void startDrag();

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void keyPressEvent( QKeyEvent arg1);

/** 
 Reimplemented for internal reasons.
 Further reimplementations should call this function or else
 some features may not work correctly.

 The API is unaffected.
   
*/
	protected native void viewportPaintEvent( QPaintEvent arg1);

/** 
 Only called by konq_listviewwidget to select the current item
 after listing. For more information look in konquerorKeyPressEvent().
   
*/
	protected native void selectCurrentItemAndEnableSelectedBySimpleMoveMode();

/** 
 Reimplemented for setFullWidth()
   
*/
	protected native void viewportResizeEvent( QResizeEvent e);

/** 
 Handle dropEvent when itemsMovable() is set to true.
   
*/
	protected native void movableDropEvent( QListViewItem parent, QListViewItem afterme);

/** 
 Where is the nearest QListViewItem that I'm going to drop?
   
*/
//	protected native void findDrop( QPoint pos, QListViewItem parent, QListViewItem after);

/** 
 A special keyPressEvent (for Konqueror-style selection).
   
*/
	protected native void konquerorKeyPressEvent( QKeyEvent arg1);

/** 
 Convert the depth of an item into its indentation in pixels
   
*/
	protected native int depthToPixels( int depth);

/** 
 Update internal settings whenever the global ones change.

   
*/
	protected native void slotSettingsChanged( int arg1);
	protected native void slotMouseButtonClicked( int btn, QListViewItem item, QPoint pos, int c);
	protected native void doneEditing( QListViewItem item, int row);

/** 
 Repaint the rect where I was drawing the drop line.
   
*/
	protected native void cleanDropVisualizer();

/** 
 Repaint the rect where I was drawing the drop rectangle.
   
*/
	protected native void cleanItemHighlighter();

/** 
 Emit the {@link contextMenu} signal. This slot is for mouse actions.
   
*/
	protected native void emitContextMenu( QListViewItem arg1, QPoint arg2, int arg3);

/** 
 Emit the {@link contextMenu} signal. This slot is for key presses.
   
*/
	protected native void emitContextMenu( KListView arg1, QListViewItem arg2);

/** 
 Accessory slot for AutoSelect

   
*/
	protected native void slotOnItem( QListViewItem item);

/** 
 Accessory slot for AutoSelect/ChangeCursorOverItem

   
*/
	protected native void slotOnViewport();

/** 
 Process AutoSelection.

   
*/
	protected native void slotAutoSelect();

/** 
 Reacts to header changes in full width mode

   
*/
	protected native void slotHeaderChanged();
	public static final int Single = QListView.Single;
	public static final int Multi = QListView.Multi;
	public static final int Extended = QListView.Extended;
	public static final int NoSelection = QListView.NoSelection;
	public static final int Konqueror = 0;
}
