]> git.saurik.com Git - wxWidgets.git/blobdiff - src/palmos/listctrl.cpp
Committed William Osborne's wxPalmOS port
[wxWidgets.git] / src / palmos / listctrl.cpp
diff --git a/src/palmos/listctrl.cpp b/src/palmos/listctrl.cpp
new file mode 100644 (file)
index 0000000..ba7bb43
--- /dev/null
@@ -0,0 +1,741 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name:        src/palmos/listctrl.cpp
+// Purpose:     wxListCtrl
+// Author:      William Osborne
+// Modified by:
+// Created:     10/13/04
+// RCS-ID:      $Id: 
+// Copyright:   (c) William Osborne
+// Licence:     wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
+    #pragma implementation "listctrl.h"
+    #pragma implementation "listctrlbase.h"
+#endif
+
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+    #pragma hdrstop
+#endif
+
+#if wxUSE_LISTCTRL && defined(__WIN95__)
+
+#ifndef WX_PRECOMP
+    #include "wx/app.h"
+    #include "wx/intl.h"
+    #include "wx/log.h"
+    #include "wx/settings.h"
+#endif
+
+#include "wx/textctrl.h"
+#include "wx/imaglist.h"
+#include "wx/listctrl.h"
+#include "wx/dcclient.h"
+
+#include "wx/palmos/private.h"
+
+#include "wx/palmos/wrapcctl.h"
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// private helper classes
+// ----------------------------------------------------------------------------
+
+// ----------------------------------------------------------------------------
+// events
+// ----------------------------------------------------------------------------
+
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_DRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_RDRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_END_LABEL_EDIT)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ITEM)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_GET_INFO)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_SET_INFO)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_SELECTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_DESELECTED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_KEY_DOWN)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_INSERT_ITEM)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_RIGHT_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_BEGIN_DRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_DRAGGING)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_END_DRAG)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_FOCUSED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
+
+#if wxUSE_EXTENDED_RTTI
+WX_DEFINE_FLAGS( wxListCtrlStyle )
+
+wxBEGIN_FLAGS( wxListCtrlStyle )
+    // new style border flags, we put them first to
+    // use them for streaming out
+    wxFLAGS_MEMBER(wxBORDER_SIMPLE)
+    wxFLAGS_MEMBER(wxBORDER_SUNKEN)
+    wxFLAGS_MEMBER(wxBORDER_DOUBLE)
+    wxFLAGS_MEMBER(wxBORDER_RAISED)
+    wxFLAGS_MEMBER(wxBORDER_STATIC)
+    wxFLAGS_MEMBER(wxBORDER_NONE)
+    
+    // old style border flags
+    wxFLAGS_MEMBER(wxSIMPLE_BORDER)
+    wxFLAGS_MEMBER(wxSUNKEN_BORDER)
+    wxFLAGS_MEMBER(wxDOUBLE_BORDER)
+    wxFLAGS_MEMBER(wxRAISED_BORDER)
+    wxFLAGS_MEMBER(wxSTATIC_BORDER)
+    wxFLAGS_MEMBER(wxBORDER)
+
+    // standard window styles
+    wxFLAGS_MEMBER(wxTAB_TRAVERSAL)
+    wxFLAGS_MEMBER(wxCLIP_CHILDREN)
+    wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW)
+    wxFLAGS_MEMBER(wxWANTS_CHARS)
+    wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE)
+    wxFLAGS_MEMBER(wxALWAYS_SHOW_SB )
+    wxFLAGS_MEMBER(wxVSCROLL)
+    wxFLAGS_MEMBER(wxHSCROLL)
+
+    wxFLAGS_MEMBER(wxLC_LIST)
+    wxFLAGS_MEMBER(wxLC_REPORT)
+    wxFLAGS_MEMBER(wxLC_ICON)
+    wxFLAGS_MEMBER(wxLC_SMALL_ICON)
+    wxFLAGS_MEMBER(wxLC_ALIGN_TOP)
+    wxFLAGS_MEMBER(wxLC_ALIGN_LEFT)
+    wxFLAGS_MEMBER(wxLC_AUTOARRANGE)
+    wxFLAGS_MEMBER(wxLC_USER_TEXT)
+    wxFLAGS_MEMBER(wxLC_EDIT_LABELS)
+    wxFLAGS_MEMBER(wxLC_NO_HEADER)
+    wxFLAGS_MEMBER(wxLC_SINGLE_SEL)
+    wxFLAGS_MEMBER(wxLC_SORT_ASCENDING)
+    wxFLAGS_MEMBER(wxLC_SORT_DESCENDING)
+    wxFLAGS_MEMBER(wxLC_VIRTUAL)
+
+wxEND_FLAGS( wxListCtrlStyle )
+
+IMPLEMENT_DYNAMIC_CLASS_XTI(wxListCtrl, wxControl,"wx/listctrl.h")
+
+wxBEGIN_PROPERTIES_TABLE(wxListCtrl)
+    wxEVENT_PROPERTY( TextUpdated , wxEVT_COMMAND_TEXT_UPDATED , wxCommandEvent ) 
+
+    wxPROPERTY_FLAGS( WindowStyle , wxListCtrlStyle , long , SetWindowStyleFlag , GetWindowStyleFlag , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
+wxEND_PROPERTIES_TABLE()
+
+wxBEGIN_HANDLERS_TABLE(wxListCtrl)
+wxEND_HANDLERS_TABLE()
+
+wxCONSTRUCTOR_5( wxListCtrl , wxWindow* , Parent , wxWindowID , Id , wxPoint , Position , wxSize , Size , long , WindowStyle ) 
+
+/*
+ TODO : Expose more information of a list's layout etc. via appropriate objects (à la NotebookPageInfo)
+*/
+#else
+IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
+#endif
+
+IMPLEMENT_DYNAMIC_CLASS(wxListView, wxListCtrl)
+IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
+
+IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent)
+
+BEGIN_EVENT_TABLE(wxListCtrl, wxControl)
+    EVT_PAINT(wxListCtrl::OnPaint)
+END_EVENT_TABLE()
+
+// ============================================================================
+// implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxListCtrl construction
+// ----------------------------------------------------------------------------
+
+void wxListCtrl::Init()
+{
+}
+
+bool wxListCtrl::Create(wxWindow *parent,
+                        wxWindowID id,
+                        const wxPoint& pos,
+                        const wxSize& size,
+                        long style,
+                        const wxValidator& validator,
+                        const wxString& name)
+{
+    return false;
+}
+
+WXDWORD wxListCtrl::MSWGetStyle(long style, WXDWORD *exstyle) const
+{
+    return 0;
+}
+
+void wxListCtrl::UpdateStyle()
+{
+}
+
+void wxListCtrl::FreeAllInternalData()
+{
+}
+
+wxListCtrl::~wxListCtrl()
+{
+}
+
+// ----------------------------------------------------------------------------
+// set/get/change style
+// ----------------------------------------------------------------------------
+
+// Add or remove a single window style
+void wxListCtrl::SetSingleStyle(long style, bool add)
+{
+}
+
+// Set the whole window style
+void wxListCtrl::SetWindowStyleFlag(long flag)
+{
+}
+
+// ----------------------------------------------------------------------------
+// accessors
+// ----------------------------------------------------------------------------
+
+/* static */ wxVisualAttributes
+wxListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+{
+    wxVisualAttributes attrs;
+
+    return attrs;
+}
+
+// Sets the foreground, i.e. text, colour
+bool wxListCtrl::SetForegroundColour(const wxColour& col)
+{
+    return false;
+}
+
+// Sets the background colour
+bool wxListCtrl::SetBackgroundColour(const wxColour& col)
+{
+    return false;
+}
+
+// Gets information about this column
+bool wxListCtrl::GetColumn(int col, wxListItem& item) const
+{
+    return false;
+}
+
+// Sets information about this column
+bool wxListCtrl::SetColumn(int col, wxListItem& item)
+{
+    return false;
+}
+
+// Gets the column width
+int wxListCtrl::GetColumnWidth(int col) const
+{
+    return 0;
+}
+
+// Sets the column width
+bool wxListCtrl::SetColumnWidth(int col, int width)
+{
+    return false;
+}
+
+// Gets the number of items that can fit vertically in the
+// visible area of the list control (list or report view)
+// or the total number of items in the list control (icon
+// or small icon view)
+int wxListCtrl::GetCountPerPage() const
+{
+    return 0;
+}
+
+// Gets the edit control for editing labels.
+wxTextCtrl* wxListCtrl::GetEditControl() const
+{
+    return NULL;
+}
+
+// Gets information about the item
+bool wxListCtrl::GetItem(wxListItem& info) const
+{
+    return false;
+}
+
+// Sets information about the item
+bool wxListCtrl::SetItem(wxListItem& info)
+{
+    return false;
+}
+
+long wxListCtrl::SetItem(long index, int col, const wxString& label, int imageId)
+{
+    return 0;
+}
+
+
+// Gets the item state
+int wxListCtrl::GetItemState(long item, long stateMask) const
+{
+    return 0;
+}
+
+// Sets the item state
+bool wxListCtrl::SetItemState(long item, long state, long stateMask)
+{
+    return false;
+}
+
+// Sets the item image
+bool wxListCtrl::SetItemImage(long item, int image, int WXUNUSED(selImage))
+{
+    return false;
+}
+
+// Gets the item text
+wxString wxListCtrl::GetItemText(long item) const
+{
+    wxListItem info;
+
+    return info.m_text;
+}
+
+// Sets the item text
+void wxListCtrl::SetItemText(long item, const wxString& str)
+{
+}
+
+// Gets the item data
+long wxListCtrl::GetItemData(long item) const
+{
+    return 0;
+}
+
+// Sets the item data
+bool wxListCtrl::SetItemData(long item, long data)
+{
+    return false;
+}
+
+wxRect wxListCtrl::GetViewRect() const
+{
+    wxRect rect;
+
+    return rect;
+}
+
+// Gets the item rectangle
+bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
+{
+    return false;
+}
+
+// Gets the item position
+bool wxListCtrl::GetItemPosition(long item, wxPoint& pos) const
+{
+    return false;
+}
+
+// Sets the item position.
+bool wxListCtrl::SetItemPosition(long item, const wxPoint& pos)
+{
+    return false;
+}
+
+// Gets the number of items in the list control
+int wxListCtrl::GetItemCount() const
+{
+    return 0;
+}
+
+wxSize wxListCtrl::GetItemSpacing() const
+{
+    return wxSize(0,0);
+}
+
+int wxListCtrl::GetItemSpacing(bool isSmall) const
+{
+    return 0;
+}
+
+void wxListCtrl::SetItemTextColour( long item, const wxColour &col )
+{
+}
+
+wxColour wxListCtrl::GetItemTextColour( long item ) const
+{
+    wxColour col;
+
+    return col;
+}
+
+void wxListCtrl::SetItemBackgroundColour( long item, const wxColour &col )
+{
+}
+
+wxColour wxListCtrl::GetItemBackgroundColour( long item ) const
+{
+    wxColour col;
+
+    return col;
+}
+
+// Gets the number of selected items in the list control
+int wxListCtrl::GetSelectedItemCount() const
+{
+    return 0;
+}
+
+// Gets the text colour of the listview
+wxColour wxListCtrl::GetTextColour() const
+{
+    wxColour col;
+    return col;
+}
+
+// Sets the text colour of the listview
+void wxListCtrl::SetTextColour(const wxColour& col)
+{
+}
+
+// Gets the index of the topmost visible item when in
+// list or report view
+long wxListCtrl::GetTopItem() const
+{
+    return 0;
+}
+
+// Searches for an item, starting from 'item'.
+// 'geometry' is one of
+// wxLIST_NEXT_ABOVE/ALL/BELOW/LEFT/RIGHT.
+// 'state' is a state bit flag, one or more of
+// wxLIST_STATE_DROPHILITED/FOCUSED/SELECTED/CUT.
+// item can be -1 to find the first item that matches the
+// specified flags.
+// Returns the item or -1 if unsuccessful.
+long wxListCtrl::GetNextItem(long item, int geom, int state) const
+{
+    return 0;
+}
+
+
+wxImageList *wxListCtrl::GetImageList(int which) const
+{
+    return NULL;
+}
+
+void wxListCtrl::SetImageList(wxImageList *imageList, int which)
+{
+}
+
+void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
+{
+}
+
+// ----------------------------------------------------------------------------
+// Operations
+// ----------------------------------------------------------------------------
+
+// Arranges the items
+bool wxListCtrl::Arrange(int flag)
+{
+    return false;
+}
+
+// Deletes an item
+bool wxListCtrl::DeleteItem(long item)
+{
+    return false;
+}
+
+// Deletes all items
+bool wxListCtrl::DeleteAllItems()
+{
+    return false;
+}
+
+// Deletes all items
+bool wxListCtrl::DeleteAllColumns()
+{
+    return false;
+}
+
+// Deletes a column
+bool wxListCtrl::DeleteColumn(int col)
+{
+    return false;
+}
+
+// Clears items, and columns if there are any.
+void wxListCtrl::ClearAll()
+{
+}
+
+wxTextCtrl* wxListCtrl::EditLabel(long item, wxClassInfo* textControlClass)
+{
+    return NULL;
+}
+
+// End label editing, optionally cancelling the edit
+bool wxListCtrl::EndEditLabel(bool WXUNUSED(cancel))
+{
+    return FALSE;
+}
+
+// Ensures this item is visible
+bool wxListCtrl::EnsureVisible(long item)
+{
+    return false;
+}
+
+// Find an item whose label matches this string, starting from the item after 'start'
+// or the beginning if 'start' is -1.
+long wxListCtrl::FindItem(long start, const wxString& str, bool partial)
+{
+    return 0;
+}
+
+// Find an item whose data matches this data, starting from the item after 'start'
+// or the beginning if 'start' is -1.
+// NOTE : Lindsay Mathieson - 14-July-2002
+//        No longer use ListView_FindItem as the data attribute is now stored
+//        in a wxListItemInternalData structure refernced by the actual lParam
+long wxListCtrl::FindItem(long start, long data)
+{
+    return -1;
+}
+
+// Find an item nearest this position in the specified direction, starting from
+// the item after 'start' or the beginning if 'start' is -1.
+long wxListCtrl::FindItem(long start, const wxPoint& pt, int direction)
+{
+    return -1;
+}
+
+// Determines which item (if any) is at the specified point,
+// giving details in 'flags' (see wxLIST_HITTEST_... flags above)
+long wxListCtrl::HitTest(const wxPoint& point, int& flags)
+{
+    return 0;
+}
+
+// Inserts an item, returning the index of the new item if successful,
+// -1 otherwise.
+long wxListCtrl::InsertItem(wxListItem& info)
+{
+    return 0;
+}
+
+long wxListCtrl::InsertItem(long index, const wxString& label)
+{
+    return 0;
+}
+
+// Inserts an image item
+long wxListCtrl::InsertItem(long index, int imageIndex)
+{
+    return 0;
+}
+
+// Inserts an image/string item
+long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
+{
+    return 0;
+}
+
+// For list view mode (only), inserts a column.
+long wxListCtrl::InsertColumn(long col, wxListItem& item)
+{
+    return 0;
+}
+
+long wxListCtrl::InsertColumn(long col,
+                              const wxString& heading,
+                              int format,
+                              int width)
+{
+    return 0;
+}
+
+// scroll the control by the given number of pixels (exception: in list view,
+// dx is interpreted as number of columns)
+bool wxListCtrl::ScrollList(int dx, int dy)
+{
+    return FALSE;
+}
+
+// Sort items.
+
+// fn is a function which takes 3 long arguments: item1, item2, data.
+// item1 is the long data associated with a first item (NOT the index).
+// item2 is the long data associated with a second item (NOT the index).
+// data is the same value as passed to SortItems.
+// The return value is a negative number if the first item should precede the second
+// item, a positive number of the second item should precede the first,
+// or zero if the two items are equivalent.
+
+// data is arbitrary data to be passed to the sort function.
+
+// Internal structures for proxying the user compare function
+// so that we can pass it the *real* user data
+
+// translate lParam data and call user func
+struct wxInternalDataSort
+{
+    wxListCtrlCompare user_fn;
+    long data;
+};
+
+int CALLBACK wxInternalDataCompareFunc(LPARAM lParam1, LPARAM lParam2,  LPARAM lParamSort)
+{
+    struct wxInternalDataSort *internalData = (struct wxInternalDataSort *) lParamSort;
+
+    wxListItemInternalData *data1 = (wxListItemInternalData *) lParam1;
+    wxListItemInternalData *data2 = (wxListItemInternalData *) lParam2;
+
+    long d1 = (data1 == NULL ? 0 : data1->lParam);
+    long d2 = (data2 == NULL ? 0 : data2->lParam);
+
+    return internalData->user_fn(d1, d2, internalData->data);
+
+};
+
+bool wxListCtrl::SortItems(wxListCtrlCompare fn, long data)
+{
+    return FALSE;
+}
+
+
+
+// ----------------------------------------------------------------------------
+// message processing
+// ----------------------------------------------------------------------------
+
+bool wxListCtrl::MSWCommand(WXUINT cmd, WXWORD id)
+{
+    return false;
+}
+
+bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
+{
+    return false;
+}
+
+// see comment at the end of wxListCtrl::GetColumn()
+#ifdef NM_CUSTOMDRAW // _WIN32_IE >= 0x0300
+
+WXLPARAM wxListCtrl::OnCustomDraw(WXLPARAM lParam)
+{
+    return CDRF_DODEFAULT;
+}
+
+#endif // NM_CUSTOMDRAW supported
+
+// Necessary for drawing hrules and vrules, if specified
+void wxListCtrl::OnPaint(wxPaintEvent& event)
+{
+}
+
+// ----------------------------------------------------------------------------
+// virtual list controls
+// ----------------------------------------------------------------------------
+
+wxString wxListCtrl::OnGetItemText(long WXUNUSED(item), long WXUNUSED(col)) const
+{
+    return wxEmptyString;
+}
+
+int wxListCtrl::OnGetItemImage(long WXUNUSED(item)) const
+{
+    return -1;
+}
+
+wxListItemAttr *wxListCtrl::OnGetItemAttr(long WXUNUSED_UNLESS_DEBUG(item)) const
+{
+    // no attributes by default
+    return NULL;
+}
+
+void wxListCtrl::SetItemCount(long count)
+{
+}
+
+void wxListCtrl::RefreshItem(long item)
+{
+}
+
+void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
+{
+}
+
+// ----------------------------------------------------------------------------
+// internal data stuff
+// ----------------------------------------------------------------------------
+
+static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId)
+{
+    return NULL;
+};
+
+static
+wxListItemInternalData *wxGetInternalData(const wxListCtrl *ctl, long itemId)
+{
+    return wxGetInternalData(GetHwndOf(ctl), itemId);
+};
+
+static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId)
+{
+    return NULL;
+};
+
+static void wxDeleteInternalData(wxListCtrl* ctl, long itemId)
+{
+}
+
+// ----------------------------------------------------------------------------
+// wxWin <-> MSW items conversions
+// ----------------------------------------------------------------------------
+
+static void wxConvertFromMSWListItem(HWND hwndListCtrl,
+                                     wxListItem& info,
+                                     LV_ITEM& lvItem)
+{
+}
+
+static void wxConvertToMSWFlags(long state, long stateMask, LV_ITEM& lvItem)
+{
+}
+
+static void wxConvertToMSWListItem(const wxListCtrl *ctrl,
+                                   const wxListItem& info,
+                                   LV_ITEM& lvItem)
+{
+}
+
+static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item,
+                                  LV_COLUMN& lvCol)
+{
+}
+
+#endif // wxUSE_LISTCTRL
+