📄 treebase.h
字号:
/////////////////////////////////////////////////////////////////////////////
// Name: treebase.h
// Purpose: wxTreeCtrl base classes and types
// Author: Julian Smart et al
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id: treebase.h,v 1.1 2005/03/16 06:49:30 kehc Exp $
// Copyright: (c) 1997,1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TREEBASE_H_
#define _WX_TREEBASE_H_
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma interface "treebase.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#if wxUSE_TREECTRL
#include "wx/window.h" // for wxClientData
#include "wx/event.h"
// ----------------------------------------------------------------------------
// wxTreeItemId identifies an element of the tree. In this implementation, it's
// just a trivial wrapper around Win32 HTREEITEM or a pointer to some private
// data structure in the generic version. It's opaque for the application and
// the only method which can be used by user code is IsOk().
// ----------------------------------------------------------------------------
// Using this typedef removes an ambiguity when calling Remove()
typedef long wxTreeItemIdValue;
class WXDLLEXPORT wxTreeItemId
{
public:
// ctors
// 0 is invalid value for HTREEITEM
wxTreeItemId() { m_pItem = 0; }
// this one is used in the generic version
wxTreeItemId(void *pItem) { m_pItem = (long) pItem; }
// and this one under MSW
wxTreeItemId(long lItem) { m_pItem = lItem; }
// default copy ctor/assignment operator are ok for us
// accessors
// is this a valid tree item?
bool IsOk() const { return m_pItem != 0; }
// deprecated: only for compatibility
operator wxTreeItemIdValue() const { return m_pItem; }
wxTreeItemIdValue m_pItem;
};
// ----------------------------------------------------------------------------
// wxTreeItemData is some (arbitrary) user class associated with some item. The
// main advantage of having this class (compared to old untyped interface) is
// that wxTreeItemData's are destroyed automatically by the tree and, as this
// class has virtual dtor, it means that the memory will be automatically
// freed. OTOH, we don't just use wxObject instead of wxTreeItemData because
// the size of this class is critical: in any real application, each tree leaf
// will have wxTreeItemData associated with it and number of leaves may be
// quite big.
//
// Because the objects of this class are deleted by the tree, they should
// always be allocated on the heap!
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeItemData: public wxClientData
{
friend class WXDLLEXPORT wxTreeCtrl;
friend class WXDLLEXPORT wxGenericTreeCtrl;
public:
// creation/destruction
// --------------------
// default ctor
wxTreeItemData() { }
// default copy ctor/assignment operator are ok
// accessor: get the item associated with us
const wxTreeItemId& GetId() const { return m_pItem; }
void SetId(const wxTreeItemId& id) { m_pItem = id; }
protected:
wxTreeItemId m_pItem;
};
WX_DEFINE_EXPORTED_ARRAY_LONG(wxTreeItemId, wxArrayTreeItemIds);
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// enum for different images associated with a treectrl item
enum wxTreeItemIcon
{
wxTreeItemIcon_Normal, // not selected, not expanded
wxTreeItemIcon_Selected, // selected, not expanded
wxTreeItemIcon_Expanded, // not selected, expanded
wxTreeItemIcon_SelectedExpanded, // selected, expanded
wxTreeItemIcon_Max
};
/*
* wxTreeCtrl flags
*/
// TODO: maybe renumber these?
#define wxTR_NO_BUTTONS 0x0000 // for convenience
#define wxTR_HAS_BUTTONS 0x0001 // generates a +/- button
#define wxTR_TWIST_BUTTONS 0x0002 // generates a twister button
#define wxTR_NO_LINES 0x0004 // don't generate level connectors
#define wxTR_LINES_AT_ROOT 0x0008 // connect top-level nodes
#define wxTR_MAC_BUTTONS wxTR_TWIST_BUTTONS // backward compatibility
#define wxTR_AQUA_BUTTONS 0x0010 // used internally
#define wxTR_SINGLE 0x0000 // for convenience
#define wxTR_MULTIPLE 0x0020 // can select multiple items
#define wxTR_EXTENDED 0x0040 // TODO: allow extended selection
#define wxTR_FULL_ROW_HIGHLIGHT 0x2000 // highlight full horizontal space
#define wxTR_EDIT_LABELS 0x0200 // can edit item labels
#define wxTR_ROW_LINES 0x0400 // put border around items
#define wxTR_HIDE_ROOT 0x0800 // don't display root node
#define wxTR_HAS_VARIABLE_ROW_HEIGHT 0x0080 // what it says
// TODO: different default styles for wxGTK, wxMotif, whatever?
#ifdef __WXMAC__
#define wxTR_DEFAULT_STYLE (wxTR_TWIST_BUTTONS|wxTR_NO_LINES|wxTR_ROW_LINES)
#else
#define wxTR_DEFAULT_STYLE (wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT)
#endif
// values for the `flags' parameter of wxTreeCtrl::HitTest() which determine
// where exactly the specified point is situated:
static const int wxTREE_HITTEST_ABOVE = 0x0001;
static const int wxTREE_HITTEST_BELOW = 0x0002;
static const int wxTREE_HITTEST_NOWHERE = 0x0004;
// on the button associated with an item.
static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0008;
// on the bitmap associated with an item.
static const int wxTREE_HITTEST_ONITEMICON = 0x0010;
// on the indent associated with an item.
static const int wxTREE_HITTEST_ONITEMINDENT = 0x0020;
// on the label (string) associated with an item.
static const int wxTREE_HITTEST_ONITEMLABEL = 0x0040;
// on the right of the label associated with an item.
static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0080;
// on the label (string) associated with an item.
static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0100;
// on the left of the wxTreeCtrl.
static const int wxTREE_HITTEST_TOLEFT = 0x0200;
// on the right of the wxTreeCtrl.
static const int wxTREE_HITTEST_TORIGHT = 0x0400;
// on the upper part (first half) of the item.
static const int wxTREE_HITTEST_ONITEMUPPERPART = 0x0800;
// on the lower part (second half) of the item.
static const int wxTREE_HITTEST_ONITEMLOWERPART = 0x1000;
// anywhere on the item
static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
wxTREE_HITTEST_ONITEMLABEL;
// tree ctrl default name
WXDLLEXPORT_DATA(extern const wxChar*) wxTreeCtrlNameStr;
// ----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -