From: Vadim Zeitlin Date: Tue, 15 Feb 2000 00:05:36 +0000 (+0000) Subject: 1. implemented wxRegKey::Copy() and CopyValue() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/23f681ec4840b44e265e6f71beef5a242306220b 1. implemented wxRegKey::Copy() and CopyValue() 2. regtest sample doesn't crash any more 3. wxLogGui uses msg box for only 1 message 4. "const wxEventType" => "enum" 5. wxEVT_COMMAND_TREE_END_DRAG introduced - see sample for example 6. fixed several non fatal bugs in wxRegKey 7. many changes in regtest sample, not tested yet git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/event.h b/include/wx/event.h index 63f6fe7e73..7531023db5 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -42,489 +42,229 @@ class WXDLLEXPORT wxList; // Event types // ---------------------------------------------------------------------------- +#if defined(__BORLANDC__) && defined(__WIN16__) + // For 16-bit BC++, these 2 would be identical otherwise (truncated) + #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED wxEVT_COMMAND_NB_PAGE_CHANGED + #define wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING wxEVT_COMMAND_NB_PAGE_CHANGING +#endif + typedef int wxEventType; -#if defined(__VISAGECPP__) && __IBMCPP__ >= 400 -// must define these static for VA or else you get multiply defined symbols everywhere -extern const wxEventType wxEVT_NULL; -extern const wxEventType wxEVT_FIRST; - -extern const wxEventType wxEVT_COMMAND_BUTTON_CLICKED; -extern const wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED; -extern const wxEventType wxEVT_COMMAND_CHOICE_SELECTED; -extern const wxEventType wxEVT_COMMAND_LISTBOX_SELECTED; -extern const wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED; -extern const wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED; -extern const wxEventType wxEVT_COMMAND_TEXT_UPDATED; -extern const wxEventType wxEVT_COMMAND_TEXT_ENTER; -extern const wxEventType wxEVT_COMMAND_MENU_SELECTED; -extern const wxEventType wxEVT_COMMAND_TOOL_CLICKED; -extern const wxEventType wxEVT_COMMAND_SLIDER_UPDATED; -extern const wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED; -extern const wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED; -extern const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED; -extern const wxEventType wxEVT_COMMAND_VLBOX_SELECTED; -extern const wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED; -extern const wxEventType wxEVT_COMMAND_TOOL_RCLICKED; -extern const wxEventType wxEVT_COMMAND_TOOL_ENTER; -extern const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED; - -/* Sockets and timers send events, too */ -extern const wxEventType wxEVT_SOCKET; -extern const wxEventType wxEVT_TIMER; - -/* Mouse event types */ -extern const wxEventType wxEVT_LEFT_DOWN; -extern const wxEventType wxEVT_LEFT_UP; -extern const wxEventType wxEVT_MIDDLE_DOWN; -extern const wxEventType wxEVT_MIDDLE_UP; -extern const wxEventType wxEVT_RIGHT_DOWN; -extern const wxEventType wxEVT_RIGHT_UP; -extern const wxEventType wxEVT_MOTION; -extern const wxEventType wxEVT_ENTER_WINDOW; -extern const wxEventType wxEVT_LEAVE_WINDOW; -extern const wxEventType wxEVT_LEFT_DCLICK; -extern const wxEventType wxEVT_MIDDLE_DCLICK; -extern const wxEventType wxEVT_RIGHT_DCLICK; -extern const wxEventType wxEVT_SET_FOCUS; -extern const wxEventType wxEVT_KILL_FOCUS; - - /* Non-client mouse events */ -extern const wxEventType wxEVT_NC_LEFT_DOWN; -extern const wxEventType wxEVT_NC_LEFT_UP; -extern const wxEventType wxEVT_NC_MIDDLE_DOWN; -extern const wxEventType wxEVT_NC_MIDDLE_UP; -extern const wxEventType wxEVT_NC_RIGHT_DOWN; -extern const wxEventType wxEVT_NC_RIGHT_UP; -extern const wxEventType wxEVT_NC_MOTION; -extern const wxEventType wxEVT_NC_ENTER_WINDOW; -extern const wxEventType wxEVT_NC_LEAVE_WINDOW; -extern const wxEventType wxEVT_NC_LEFT_DCLICK; -extern const wxEventType wxEVT_NC_MIDDLE_DCLICK; -extern const wxEventType wxEVT_NC_RIGHT_DCLICK; - -/* Character input event type */ -extern const wxEventType wxEVT_CHAR; -extern const wxEventType wxEVT_CHAR_HOOK; -extern const wxEventType wxEVT_NAVIGATION_KEY; -extern const wxEventType wxEVT_KEY_DOWN; -extern const wxEventType wxEVT_KEY_UP; - - /* - * wxScrollbar and wxSlider event identifiers - */ -extern const wxEventType wxEVT_SCROLL_TOP; -extern const wxEventType wxEVT_SCROLL_BOTTOM; -extern const wxEventType wxEVT_SCROLL_LINEUP; -extern const wxEventType wxEVT_SCROLL_LINEDOWN; -extern const wxEventType wxEVT_SCROLL_PAGEUP; -extern const wxEventType wxEVT_SCROLL_PAGEDOWN; -extern const wxEventType wxEVT_SCROLL_THUMBTRACK; -extern const wxEventType wxEVT_SCROLL_THUMBRELEASE; - - /* - * Scroll events from wxWindow - */ -extern const wxEventType wxEVT_SCROLLWIN_TOP; -extern const wxEventType wxEVT_SCROLLWIN_BOTTOM; -extern const wxEventType wxEVT_SCROLLWIN_LINEUP; -extern const wxEventType wxEVT_SCROLLWIN_LINEDOWN; -extern const wxEventType wxEVT_SCROLLWIN_PAGEUP; -extern const wxEventType wxEVT_SCROLLWIN_PAGEDOWN; -extern const wxEventType wxEVT_SCROLLWIN_THUMBTRACK; -extern const wxEventType wxEVT_SCROLLWIN_THUMBRELEASE; - - /* - * System events - */ -extern const wxEventType wxEVT_SIZE; -extern const wxEventType wxEVT_MOVE; -extern const wxEventType wxEVT_CLOSE_WINDOW; -extern const wxEventType wxEVT_END_SESSION; -extern const wxEventType wxEVT_QUERY_END_SESSION; -extern const wxEventType wxEVT_ACTIVATE_APP; -extern const wxEventType wxEVT_POWER; -extern const wxEventType wxEVT_ACTIVATE; -extern const wxEventType wxEVT_CREATE; -extern const wxEventType wxEVT_DESTROY; -extern const wxEventType wxEVT_SHOW; -extern const wxEventType wxEVT_ICONIZE; -extern const wxEventType wxEVT_MAXIMIZE; -extern const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED; -extern const wxEventType wxEVT_PAINT; -extern const wxEventType wxEVT_ERASE_BACKGROUND; -extern const wxEventType wxEVT_NC_PAINT; -extern const wxEventType wxEVT_PAINT_ICON; -extern const wxEventType wxEVT_MENU_CHAR; -extern const wxEventType wxEVT_MENU_INIT; -extern const wxEventType wxEVT_MENU_HIGHLIGHT; -extern const wxEventType wxEVT_POPUP_MENU_INIT; -extern const wxEventType wxEVT_CONTEXT_MENU; -extern const wxEventType wxEVT_SYS_COLOUR_CHANGED; -extern const wxEventType wxEVT_SETTING_CHANGED; -extern const wxEventType wxEVT_QUERY_NEW_PALETTE; -extern const wxEventType wxEVT_PALETTE_CHANGED; -extern const wxEventType wxEVT_JOY_BUTTON_DOWN; -extern const wxEventType wxEVT_JOY_BUTTON_UP; -extern const wxEventType wxEVT_JOY_MOVE; -extern const wxEventType wxEVT_JOY_ZMOVE; -extern const wxEventType wxEVT_DROP_FILES; -extern const wxEventType wxEVT_DRAW_ITEM; -extern const wxEventType wxEVT_MEASURE_ITEM; -extern const wxEventType wxEVT_COMPARE_ITEM; -extern const wxEventType wxEVT_INIT_DIALOG; -extern const wxEventType wxEVT_IDLE; -extern const wxEventType wxEVT_UPDATE_UI; - - /* System misc. */ -extern const wxEventType wxEVT_END_PROCESS; - - /* Dial up events */ -extern const wxEventType wxEVT_DIALUP_CONNECTED; -extern const wxEventType wxEVT_DIALUP_DISCONNECTED; - - /* Generic command events */ - /* Note: a click is a higher-level event than button down/up */ -extern const wxEventType wxEVT_COMMAND_LEFT_CLICK; -extern const wxEventType wxEVT_COMMAND_LEFT_DCLICK; -extern const wxEventType wxEVT_COMMAND_RIGHT_CLICK; -extern const wxEventType wxEVT_COMMAND_RIGHT_DCLICK; -extern const wxEventType wxEVT_COMMAND_SET_FOCUS; -extern const wxEventType wxEVT_COMMAND_KILL_FOCUS; -extern const wxEventType wxEVT_COMMAND_ENTER; - - /* Tree control event types */ -extern const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG; -extern const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG; -extern const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT; -extern const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT; -extern const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM; -extern const wxEventType wxEVT_COMMAND_TREE_GET_INFO; -extern const wxEventType wxEVT_COMMAND_TREE_SET_INFO; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING; -extern const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED; -extern const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING; -extern const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK; -extern const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK; - - /* List control event types */ -extern const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG; -extern const wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG; -extern const wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT; -extern const wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT; -extern const wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM; -extern const wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS; -extern const wxEventType wxEVT_COMMAND_LIST_GET_INFO; -extern const wxEventType wxEVT_COMMAND_LIST_SET_INFO; -extern const wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED; -extern const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED; -extern const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN; -extern const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM; -extern const wxEventType wxEVT_COMMAND_LIST_COL_CLICK; -extern const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK; -extern const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK; -extern const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED; - - /* Tab and notebook control event types */ -extern const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED; -extern const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING; -extern const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED; -extern const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING; - -/* Splitter events */ -extern const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED; -extern const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING; -extern const wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED; -extern const wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT; - -/* Wizard events */ -extern const wxEventType wxEVT_WIZARD_PAGE_CHANGED; -extern const wxEventType wxEVT_WIZARD_PAGE_CHANGING; -extern const wxEventType wxEVT_WIZARD_CANCEL; - -/* Calendar events */ -extern const wxEventType wxEVT_CALENDAR_SEL_CHANGED; -extern const wxEventType wxEVT_CALENDAR_DAY_CHANGED; -extern const wxEventType wxEVT_CALENDAR_MONTH_CHANGED; -extern const wxEventType wxEVT_CALENDAR_YEAR_CHANGED; -extern const wxEventType wxEVT_CALENDAR_DOUBLECLICKED; -extern const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED; - -/* Plot events */ -extern const wxEventType wxEVT_PLOT_SEL_CHANGING; -extern const wxEventType wxEVT_PLOT_SEL_CHANGED; -extern const wxEventType wxEVT_PLOT_CLICKED; -extern const wxEventType wxEVT_PLOT_DOUBLECLICKED; -extern const wxEventType wxEVT_PLOT_ZOOM_IN; -extern const wxEventType wxEVT_PLOT_ZOOM_OUT; -extern const wxEventType wxEVT_PLOT_VALUE_SEL_CREATING; -extern const wxEventType wxEVT_PLOT_VALUE_SEL_CREATED; -extern const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGING; -extern const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGED; -extern const wxEventType wxEVT_PLOT_AREA_SEL_CREATING; -extern const wxEventType wxEVT_PLOT_AREA_SEL_CREATED; -extern const wxEventType wxEVT_PLOT_AREA_SEL_CHANGING; -extern const wxEventType wxEVT_PLOT_AREA_SEL_CHANGED; -extern const wxEventType wxEVT_PLOT_BEGIN_X_LABEL_EDIT; -extern const wxEventType wxEVT_PLOT_END_X_LABEL_EDIT; -extern const wxEventType wxEVT_PLOT_BEGIN_Y_LABEL_EDIT; -extern const wxEventType wxEVT_PLOT_END_Y_LABEL_EDIT; -extern const wxEventType wxEVT_PLOT_BEGIN_TITLE_EDIT; -extern const wxEventType wxEVT_PLOT_END_TITLE_EDIT; - -extern const wxEventType wxEVT_USER_FIRST; - -#else // everybody else - -const wxEventType wxEVT_NULL = 0; -const wxEventType wxEVT_FIRST = 10000; - -const wxEventType wxEVT_COMMAND_BUTTON_CLICKED = wxEVT_FIRST + 1; -const wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED = wxEVT_FIRST + 2; -const wxEventType wxEVT_COMMAND_CHOICE_SELECTED = wxEVT_FIRST + 3; -const wxEventType wxEVT_COMMAND_LISTBOX_SELECTED = wxEVT_FIRST + 4; -const wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxEVT_FIRST + 5; -const wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxEVT_FIRST + 6; -const wxEventType wxEVT_COMMAND_TEXT_UPDATED = wxEVT_FIRST + 7; -const wxEventType wxEVT_COMMAND_TEXT_ENTER = wxEVT_FIRST + 8; -const wxEventType wxEVT_COMMAND_MENU_SELECTED = wxEVT_FIRST + 9; -const wxEventType wxEVT_COMMAND_TOOL_CLICKED = wxEVT_COMMAND_MENU_SELECTED; -const wxEventType wxEVT_COMMAND_SLIDER_UPDATED = wxEVT_FIRST + 10; -const wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED = wxEVT_FIRST + 11; -const wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED = wxEVT_FIRST + 12; -//const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use wxEVT_SCROLL... events -const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED = wxEVT_FIRST + 13; -const wxEventType wxEVT_COMMAND_VLBOX_SELECTED = wxEVT_FIRST + 14; -const wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED = wxEVT_FIRST + 15; -const wxEventType wxEVT_COMMAND_TOOL_RCLICKED = wxEVT_FIRST + 16; -const wxEventType wxEVT_COMMAND_TOOL_ENTER = wxEVT_FIRST + 17; -const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED = wxEVT_FIRST + 18; - -/* Sockets send events, too */ -const wxEventType wxEVT_SOCKET = wxEVT_FIRST + 50; - -/* And timers do as well */ -const wxEventType wxEVT_TIMER = wxEVT_FIRST + 80; - -/* Mouse event types */ -const wxEventType wxEVT_LEFT_DOWN = wxEVT_FIRST + 100; -const wxEventType wxEVT_LEFT_UP = wxEVT_FIRST + 101; -const wxEventType wxEVT_MIDDLE_DOWN = wxEVT_FIRST + 102; -const wxEventType wxEVT_MIDDLE_UP = wxEVT_FIRST + 103; -const wxEventType wxEVT_RIGHT_DOWN = wxEVT_FIRST + 104; -const wxEventType wxEVT_RIGHT_UP = wxEVT_FIRST + 105; -const wxEventType wxEVT_MOTION = wxEVT_FIRST + 106; -const wxEventType wxEVT_ENTER_WINDOW = wxEVT_FIRST + 107; -const wxEventType wxEVT_LEAVE_WINDOW = wxEVT_FIRST + 108; -const wxEventType wxEVT_LEFT_DCLICK = wxEVT_FIRST + 109; -const wxEventType wxEVT_MIDDLE_DCLICK = wxEVT_FIRST + 110; -const wxEventType wxEVT_RIGHT_DCLICK = wxEVT_FIRST + 111; -const wxEventType wxEVT_SET_FOCUS = wxEVT_FIRST + 112; -const wxEventType wxEVT_KILL_FOCUS = wxEVT_FIRST + 113; - - /* Non-client mouse events */ -const wxEventType wxEVT_NC_LEFT_DOWN = wxEVT_FIRST + 200; -const wxEventType wxEVT_NC_LEFT_UP = wxEVT_FIRST + 201; -const wxEventType wxEVT_NC_MIDDLE_DOWN = wxEVT_FIRST + 202; -const wxEventType wxEVT_NC_MIDDLE_UP = wxEVT_FIRST + 203; -const wxEventType wxEVT_NC_RIGHT_DOWN = wxEVT_FIRST + 204; -const wxEventType wxEVT_NC_RIGHT_UP = wxEVT_FIRST + 205; -const wxEventType wxEVT_NC_MOTION = wxEVT_FIRST + 206; -const wxEventType wxEVT_NC_ENTER_WINDOW = wxEVT_FIRST + 207; -const wxEventType wxEVT_NC_LEAVE_WINDOW = wxEVT_FIRST + 208; -const wxEventType wxEVT_NC_LEFT_DCLICK = wxEVT_FIRST + 209; -const wxEventType wxEVT_NC_MIDDLE_DCLICK = wxEVT_FIRST + 210; -const wxEventType wxEVT_NC_RIGHT_DCLICK = wxEVT_FIRST + 211; - -/* Character input event type */ -const wxEventType wxEVT_CHAR = wxEVT_FIRST + 212; -const wxEventType wxEVT_CHAR_HOOK = wxEVT_FIRST + 213; -const wxEventType wxEVT_NAVIGATION_KEY = wxEVT_FIRST + 214; -const wxEventType wxEVT_KEY_DOWN = wxEVT_FIRST + 215; -const wxEventType wxEVT_KEY_UP = wxEVT_FIRST + 216; - - /* - * wxScrollbar and wxSlider event identifiers - */ -const wxEventType wxEVT_SCROLL_TOP = wxEVT_FIRST + 300; -const wxEventType wxEVT_SCROLL_BOTTOM = wxEVT_FIRST + 301; -const wxEventType wxEVT_SCROLL_LINEUP = wxEVT_FIRST + 302; -const wxEventType wxEVT_SCROLL_LINEDOWN = wxEVT_FIRST + 303; -const wxEventType wxEVT_SCROLL_PAGEUP = wxEVT_FIRST + 304; -const wxEventType wxEVT_SCROLL_PAGEDOWN = wxEVT_FIRST + 305; -const wxEventType wxEVT_SCROLL_THUMBTRACK = wxEVT_FIRST + 306; -const wxEventType wxEVT_SCROLL_THUMBRELEASE = wxEVT_FIRST + 307; - - /* - * Scroll events from wxWindow - */ -const wxEventType wxEVT_SCROLLWIN_TOP = wxEVT_FIRST + 320; -const wxEventType wxEVT_SCROLLWIN_BOTTOM = wxEVT_FIRST + 321; -const wxEventType wxEVT_SCROLLWIN_LINEUP = wxEVT_FIRST + 322; -const wxEventType wxEVT_SCROLLWIN_LINEDOWN = wxEVT_FIRST + 323; -const wxEventType wxEVT_SCROLLWIN_PAGEUP = wxEVT_FIRST + 324; -const wxEventType wxEVT_SCROLLWIN_PAGEDOWN = wxEVT_FIRST + 325; -const wxEventType wxEVT_SCROLLWIN_THUMBTRACK = wxEVT_FIRST + 326; -const wxEventType wxEVT_SCROLLWIN_THUMBRELEASE = wxEVT_FIRST + 327; - - /* - * System events - */ -const wxEventType wxEVT_SIZE = wxEVT_FIRST + 400; -const wxEventType wxEVT_MOVE = wxEVT_FIRST + 401; -const wxEventType wxEVT_CLOSE_WINDOW = wxEVT_FIRST + 402; -const wxEventType wxEVT_END_SESSION = wxEVT_FIRST + 403; -const wxEventType wxEVT_QUERY_END_SESSION = wxEVT_FIRST + 404; -const wxEventType wxEVT_ACTIVATE_APP = wxEVT_FIRST + 405; -const wxEventType wxEVT_POWER = wxEVT_FIRST + 406; -const wxEventType wxEVT_ACTIVATE = wxEVT_FIRST + 409; -const wxEventType wxEVT_CREATE = wxEVT_FIRST + 410; -const wxEventType wxEVT_DESTROY = wxEVT_FIRST + 411; -const wxEventType wxEVT_SHOW = wxEVT_FIRST + 412; -const wxEventType wxEVT_ICONIZE = wxEVT_FIRST + 413; -const wxEventType wxEVT_MAXIMIZE = wxEVT_FIRST + 414; -const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED = wxEVT_FIRST + 415; -const wxEventType wxEVT_PAINT = wxEVT_FIRST + 416; -const wxEventType wxEVT_ERASE_BACKGROUND = wxEVT_FIRST + 417; -const wxEventType wxEVT_NC_PAINT = wxEVT_FIRST + 418; -const wxEventType wxEVT_PAINT_ICON = wxEVT_FIRST + 419; -const wxEventType wxEVT_MENU_CHAR = wxEVT_FIRST + 420; -const wxEventType wxEVT_MENU_INIT = wxEVT_FIRST + 421; -const wxEventType wxEVT_MENU_HIGHLIGHT = wxEVT_FIRST + 422; -const wxEventType wxEVT_POPUP_MENU_INIT = wxEVT_FIRST + 423; -const wxEventType wxEVT_CONTEXT_MENU = wxEVT_FIRST + 424; -const wxEventType wxEVT_SYS_COLOUR_CHANGED = wxEVT_FIRST + 425; -const wxEventType wxEVT_SETTING_CHANGED = wxEVT_FIRST + 426; -const wxEventType wxEVT_QUERY_NEW_PALETTE = wxEVT_FIRST + 427; -const wxEventType wxEVT_PALETTE_CHANGED = wxEVT_FIRST + 428; -const wxEventType wxEVT_JOY_BUTTON_DOWN = wxEVT_FIRST + 429; -const wxEventType wxEVT_JOY_BUTTON_UP = wxEVT_FIRST + 430; -const wxEventType wxEVT_JOY_MOVE = wxEVT_FIRST + 431; -const wxEventType wxEVT_JOY_ZMOVE = wxEVT_FIRST + 432; -const wxEventType wxEVT_DROP_FILES = wxEVT_FIRST + 433; -const wxEventType wxEVT_DRAW_ITEM = wxEVT_FIRST + 434; -const wxEventType wxEVT_MEASURE_ITEM = wxEVT_FIRST + 435; -const wxEventType wxEVT_COMPARE_ITEM = wxEVT_FIRST + 436; -const wxEventType wxEVT_INIT_DIALOG = wxEVT_FIRST + 437; -const wxEventType wxEVT_IDLE = wxEVT_FIRST + 438; -const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439; - - /* System misc. */ -const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440; - - /* Dial up events */ -const wxEventType wxEVT_DIALUP_CONNECTED = wxEVT_FIRST + 450; -const wxEventType wxEVT_DIALUP_DISCONNECTED = wxEVT_FIRST + 451; - - /* Generic command events */ - /* Note: a click is a higher-level event than button down/up */ -const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500; -const wxEventType wxEVT_COMMAND_LEFT_DCLICK = wxEVT_FIRST + 501; -const wxEventType wxEVT_COMMAND_RIGHT_CLICK = wxEVT_FIRST + 502; -const wxEventType wxEVT_COMMAND_RIGHT_DCLICK = wxEVT_FIRST + 503; -const wxEventType wxEVT_COMMAND_SET_FOCUS = wxEVT_FIRST + 504; -const wxEventType wxEVT_COMMAND_KILL_FOCUS = wxEVT_FIRST + 505; -const wxEventType wxEVT_COMMAND_ENTER = wxEVT_FIRST + 506; - - /* Tree control event types */ -const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG = wxEVT_FIRST + 600; -const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG = wxEVT_FIRST + 601; -const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wxEVT_FIRST + 602; -const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT = wxEVT_FIRST + 603; -const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM = wxEVT_FIRST + 604; -const wxEventType wxEVT_COMMAND_TREE_GET_INFO = wxEVT_FIRST + 605; -const wxEventType wxEVT_COMMAND_TREE_SET_INFO = wxEVT_FIRST + 606; -const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED = wxEVT_FIRST + 607; -const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING = wxEVT_FIRST + 608; -const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wxEVT_FIRST + 609; -const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxEVT_FIRST + 610; -const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611; -const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612; -const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613; -const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxEVT_FIRST + 614; -const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxEVT_FIRST + 615; -const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 616; - - /* List control event types */ -const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700; -const wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxEVT_FIRST + 701; -const wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxEVT_FIRST + 702; -const wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT = wxEVT_FIRST + 703; -const wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM = wxEVT_FIRST + 704; -const wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wxEVT_FIRST + 705; -const wxEventType wxEVT_COMMAND_LIST_GET_INFO = wxEVT_FIRST + 706; -const wxEventType wxEVT_COMMAND_LIST_SET_INFO = wxEVT_FIRST + 707; -const wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED = wxEVT_FIRST + 708; -const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxEVT_FIRST + 709; -const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN = wxEVT_FIRST + 710; -const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM = wxEVT_FIRST + 711; -const wxEventType wxEVT_COMMAND_LIST_COL_CLICK = wxEVT_FIRST + 712; -const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713; -const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714; -const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxEVT_FIRST + 715; - - /* Tab and notebook control event types */ -const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800; -const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING = wxEVT_FIRST + 801; +// the standard event types +enum +{ + wxEVT_NULL = 0, + wxEVT_FIRST = 10000, + + wxEVT_COMMAND_BUTTON_CLICKED = wxEVT_FIRST + 1, + wxEVT_COMMAND_CHECKBOX_CLICKED = wxEVT_FIRST + 2, + wxEVT_COMMAND_CHOICE_SELECTED = wxEVT_FIRST + 3, + wxEVT_COMMAND_LISTBOX_SELECTED = wxEVT_FIRST + 4, + wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxEVT_FIRST + 5, + wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxEVT_FIRST + 6, + wxEVT_COMMAND_TEXT_UPDATED = wxEVT_FIRST + 7, + wxEVT_COMMAND_TEXT_ENTER = wxEVT_FIRST + 8, + wxEVT_COMMAND_MENU_SELECTED = wxEVT_FIRST + 9, + wxEVT_COMMAND_TOOL_CLICKED = wxEVT_COMMAND_MENU_SELECTED, + wxEVT_COMMAND_SLIDER_UPDATED = wxEVT_FIRST + 10, + wxEVT_COMMAND_RADIOBOX_SELECTED = wxEVT_FIRST + 11, + wxEVT_COMMAND_RADIOBUTTON_SELECTED = wxEVT_FIRST + 12, + //wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use wxEVT_SCROLL... events + wxEVT_COMMAND_SCROLLBAR_UPDATED = wxEVT_FIRST + 13, + wxEVT_COMMAND_VLBOX_SELECTED = wxEVT_FIRST + 14, + wxEVT_COMMAND_COMBOBOX_SELECTED = wxEVT_FIRST + 15, + wxEVT_COMMAND_TOOL_RCLICKED = wxEVT_FIRST + 16, + wxEVT_COMMAND_TOOL_ENTER = wxEVT_FIRST + 17, + wxEVT_COMMAND_SPINCTRL_UPDATED = wxEVT_FIRST + 18, + + /* Sockets and timers send events, too */ + wxEVT_SOCKET = wxEVT_FIRST + 50, + wxEVT_TIMER = wxEVT_FIRST + 80, + + /* Mouse event types */ + wxEVT_LEFT_DOWN = wxEVT_FIRST + 100, + wxEVT_LEFT_UP = wxEVT_FIRST + 101, + wxEVT_MIDDLE_DOWN = wxEVT_FIRST + 102, + wxEVT_MIDDLE_UP = wxEVT_FIRST + 103, + wxEVT_RIGHT_DOWN = wxEVT_FIRST + 104, + wxEVT_RIGHT_UP = wxEVT_FIRST + 105, + wxEVT_MOTION = wxEVT_FIRST + 106, + wxEVT_ENTER_WINDOW = wxEVT_FIRST + 107, + wxEVT_LEAVE_WINDOW = wxEVT_FIRST + 108, + wxEVT_LEFT_DCLICK = wxEVT_FIRST + 109, + wxEVT_MIDDLE_DCLICK = wxEVT_FIRST + 110, + wxEVT_RIGHT_DCLICK = wxEVT_FIRST + 111, + wxEVT_SET_FOCUS = wxEVT_FIRST + 112, + wxEVT_KILL_FOCUS = wxEVT_FIRST + 113, + + /* Non-client mouse events */ + wxEVT_NC_LEFT_DOWN = wxEVT_FIRST + 200, + wxEVT_NC_LEFT_UP = wxEVT_FIRST + 201, + wxEVT_NC_MIDDLE_DOWN = wxEVT_FIRST + 202, + wxEVT_NC_MIDDLE_UP = wxEVT_FIRST + 203, + wxEVT_NC_RIGHT_DOWN = wxEVT_FIRST + 204, + wxEVT_NC_RIGHT_UP = wxEVT_FIRST + 205, + wxEVT_NC_MOTION = wxEVT_FIRST + 206, + wxEVT_NC_ENTER_WINDOW = wxEVT_FIRST + 207, + wxEVT_NC_LEAVE_WINDOW = wxEVT_FIRST + 208, + wxEVT_NC_LEFT_DCLICK = wxEVT_FIRST + 209, + wxEVT_NC_MIDDLE_DCLICK = wxEVT_FIRST + 210, + wxEVT_NC_RIGHT_DCLICK = wxEVT_FIRST + 211, + + /* Character input event type */ + wxEVT_CHAR = wxEVT_FIRST + 212, + wxEVT_CHAR_HOOK = wxEVT_FIRST + 213, + wxEVT_NAVIGATION_KEY = wxEVT_FIRST + 214, + wxEVT_KEY_DOWN = wxEVT_FIRST + 215, + wxEVT_KEY_UP = wxEVT_FIRST + 216, -#if defined(__BORLANDC__) && defined(__WIN16__) -/* For 16-bit BC++, these 2 are identical (truncated) */ -const wxEventType wxEVT_COMMAND_NB_PAGE_CHANGED = wxEVT_FIRST + 802; -const wxEventType wxEVT_COMMAND_NB_PAGE_CHANGING = wxEVT_FIRST + 803; -#else -const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxEVT_FIRST + 802; -const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxEVT_FIRST + 803; -#endif + /* + * wxScrollbar and wxSlider event identifiers + */ + wxEVT_SCROLL_TOP = wxEVT_FIRST + 300, + wxEVT_SCROLL_BOTTOM = wxEVT_FIRST + 301, + wxEVT_SCROLL_LINEUP = wxEVT_FIRST + 302, + wxEVT_SCROLL_LINEDOWN = wxEVT_FIRST + 303, + wxEVT_SCROLL_PAGEUP = wxEVT_FIRST + 304, + wxEVT_SCROLL_PAGEDOWN = wxEVT_FIRST + 305, + wxEVT_SCROLL_THUMBTRACK = wxEVT_FIRST + 306, -/* Splitter events */ -const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED = wxEVT_FIRST + 850; -const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING = wxEVT_FIRST + 851; -const wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED = wxEVT_FIRST + 852; -const wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT = wxEVT_FIRST + 853; - -/* Wizard events */ -const wxEventType wxEVT_WIZARD_PAGE_CHANGED = wxEVT_FIRST + 900; -const wxEventType wxEVT_WIZARD_PAGE_CHANGING = wxEVT_FIRST + 901; -const wxEventType wxEVT_WIZARD_CANCEL = wxEVT_FIRST + 902; - -/* Calendar events */ -const wxEventType wxEVT_CALENDAR_SEL_CHANGED = wxEVT_FIRST + 950; -const wxEventType wxEVT_CALENDAR_DAY_CHANGED = wxEVT_FIRST + 951; -const wxEventType wxEVT_CALENDAR_MONTH_CHANGED = wxEVT_FIRST + 952; -const wxEventType wxEVT_CALENDAR_YEAR_CHANGED = wxEVT_FIRST + 953; -const wxEventType wxEVT_CALENDAR_DOUBLECLICKED = wxEVT_FIRST + 954; -const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED = wxEVT_FIRST + 955; - -/* Plot events */ -const wxEventType wxEVT_PLOT_SEL_CHANGING = wxEVT_FIRST + 1000; -const wxEventType wxEVT_PLOT_SEL_CHANGED = wxEVT_FIRST + 1001; -const wxEventType wxEVT_PLOT_CLICKED = wxEVT_FIRST + 1002; -const wxEventType wxEVT_PLOT_DOUBLECLICKED = wxEVT_FIRST + 1003; -const wxEventType wxEVT_PLOT_ZOOM_IN = wxEVT_FIRST + 1004; -const wxEventType wxEVT_PLOT_ZOOM_OUT = wxEVT_FIRST + 1005; -const wxEventType wxEVT_PLOT_VALUE_SEL_CREATING = wxEVT_FIRST + 1010; -const wxEventType wxEVT_PLOT_VALUE_SEL_CREATED = wxEVT_FIRST + 1011; -const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGING = wxEVT_FIRST + 1012; -const wxEventType wxEVT_PLOT_VALUE_SEL_CHANGED = wxEVT_FIRST + 1013; -const wxEventType wxEVT_PLOT_AREA_SEL_CREATING = wxEVT_FIRST + 1014; -const wxEventType wxEVT_PLOT_AREA_SEL_CREATED = wxEVT_FIRST + 1015; -const wxEventType wxEVT_PLOT_AREA_SEL_CHANGING = wxEVT_FIRST + 1016; -const wxEventType wxEVT_PLOT_AREA_SEL_CHANGED = wxEVT_FIRST + 1017; -const wxEventType wxEVT_PLOT_BEGIN_X_LABEL_EDIT = wxEVT_FIRST + 1020; -const wxEventType wxEVT_PLOT_END_X_LABEL_EDIT = wxEVT_FIRST + 1021; -const wxEventType wxEVT_PLOT_BEGIN_Y_LABEL_EDIT = wxEVT_FIRST + 1022; -const wxEventType wxEVT_PLOT_END_Y_LABEL_EDIT = wxEVT_FIRST + 1023; -const wxEventType wxEVT_PLOT_BEGIN_TITLE_EDIT = wxEVT_FIRST + 1024; -const wxEventType wxEVT_PLOT_END_TITLE_EDIT = wxEVT_FIRST + 1025; - -const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; - -#endif // for VisualAge C++ V4.0 + /* + * Scroll events from wxWindow + */ + wxEVT_SCROLLWIN_TOP = wxEVT_FIRST + 320, + wxEVT_SCROLLWIN_BOTTOM = wxEVT_FIRST + 321, + wxEVT_SCROLLWIN_LINEUP = wxEVT_FIRST + 322, + wxEVT_SCROLLWIN_LINEDOWN = wxEVT_FIRST + 323, + wxEVT_SCROLLWIN_PAGEUP = wxEVT_FIRST + 324, + wxEVT_SCROLLWIN_PAGEDOWN = wxEVT_FIRST + 325, + wxEVT_SCROLLWIN_THUMBTRACK = wxEVT_FIRST + 326, + wxEVT_SCROLL_THUMBRELEASE = wxEVT_FIRST + 327, + + /* + * System events + */ + wxEVT_SIZE = wxEVT_FIRST + 400, + wxEVT_MOVE = wxEVT_FIRST + 401, + wxEVT_CLOSE_WINDOW = wxEVT_FIRST + 402, + wxEVT_END_SESSION = wxEVT_FIRST + 403, + wxEVT_QUERY_END_SESSION = wxEVT_FIRST + 404, + wxEVT_ACTIVATE_APP = wxEVT_FIRST + 405, + wxEVT_POWER = wxEVT_FIRST + 406, + wxEVT_ACTIVATE = wxEVT_FIRST + 409, + wxEVT_CREATE = wxEVT_FIRST + 410, + wxEVT_DESTROY = wxEVT_FIRST + 411, + wxEVT_SHOW = wxEVT_FIRST + 412, + wxEVT_ICONIZE = wxEVT_FIRST + 413, + wxEVT_MAXIMIZE = wxEVT_FIRST + 414, + wxEVT_MOUSE_CAPTURE_CHANGED = wxEVT_FIRST + 415, + wxEVT_PAINT = wxEVT_FIRST + 416, + wxEVT_ERASE_BACKGROUND = wxEVT_FIRST + 417, + wxEVT_NC_PAINT = wxEVT_FIRST + 418, + wxEVT_PAINT_ICON = wxEVT_FIRST + 419, + wxEVT_MENU_CHAR = wxEVT_FIRST + 420, + wxEVT_MENU_INIT = wxEVT_FIRST + 421, + wxEVT_MENU_HIGHLIGHT = wxEVT_FIRST + 422, + wxEVT_POPUP_MENU_INIT = wxEVT_FIRST + 423, + wxEVT_CONTEXT_MENU = wxEVT_FIRST + 424, + wxEVT_SYS_COLOUR_CHANGED = wxEVT_FIRST + 425, + wxEVT_SETTING_CHANGED = wxEVT_FIRST + 426, + wxEVT_QUERY_NEW_PALETTE = wxEVT_FIRST + 427, + wxEVT_PALETTE_CHANGED = wxEVT_FIRST + 428, + wxEVT_JOY_BUTTON_DOWN = wxEVT_FIRST + 429, + wxEVT_JOY_BUTTON_UP = wxEVT_FIRST + 430, + wxEVT_JOY_MOVE = wxEVT_FIRST + 431, + wxEVT_JOY_ZMOVE = wxEVT_FIRST + 432, + wxEVT_DROP_FILES = wxEVT_FIRST + 433, + wxEVT_DRAW_ITEM = wxEVT_FIRST + 434, + wxEVT_MEASURE_ITEM = wxEVT_FIRST + 435, + wxEVT_COMPARE_ITEM = wxEVT_FIRST + 436, + wxEVT_INIT_DIALOG = wxEVT_FIRST + 437, + wxEVT_IDLE = wxEVT_FIRST + 438, + wxEVT_UPDATE_UI = wxEVT_FIRST + 439, + + /* System misc. */ + wxEVT_END_PROCESS = wxEVT_FIRST + 440, + + /* Dial up events */ + wxEVT_DIALUP_CONNECTED = wxEVT_FIRST + 450, + wxEVT_DIALUP_DISCONNECTED = wxEVT_FIRST + 451, + + /* Generic command events */ + /* Note: a click is a higher-level event than button down/up */ + wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500, + wxEVT_COMMAND_LEFT_DCLICK = wxEVT_FIRST + 501, + wxEVT_COMMAND_RIGHT_CLICK = wxEVT_FIRST + 502, + wxEVT_COMMAND_RIGHT_DCLICK = wxEVT_FIRST + 503, + wxEVT_COMMAND_SET_FOCUS = wxEVT_FIRST + 504, + wxEVT_COMMAND_KILL_FOCUS = wxEVT_FIRST + 505, + wxEVT_COMMAND_ENTER = wxEVT_FIRST + 506, + + /* Tree control event types */ + wxEVT_COMMAND_TREE_BEGIN_DRAG = wxEVT_FIRST + 600, + wxEVT_COMMAND_TREE_BEGIN_RDRAG = wxEVT_FIRST + 601, + wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wxEVT_FIRST + 602, + wxEVT_COMMAND_TREE_END_LABEL_EDIT = wxEVT_FIRST + 603, + wxEVT_COMMAND_TREE_DELETE_ITEM = wxEVT_FIRST + 604, + wxEVT_COMMAND_TREE_GET_INFO = wxEVT_FIRST + 605, + wxEVT_COMMAND_TREE_SET_INFO = wxEVT_FIRST + 606, + wxEVT_COMMAND_TREE_ITEM_EXPANDED = wxEVT_FIRST + 607, + wxEVT_COMMAND_TREE_ITEM_EXPANDING = wxEVT_FIRST + 608, + wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wxEVT_FIRST + 609, + wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxEVT_FIRST + 610, + wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611, + wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612, + wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613, + wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxEVT_FIRST + 614, + wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxEVT_FIRST + 615, + wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 616, + wxEVT_COMMAND_TREE_END_DRAG = wxEVT_FIRST + 617, + + /* List control event types */ + wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700, + wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxEVT_FIRST + 701, + wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxEVT_FIRST + 702, + wxEVT_COMMAND_LIST_END_LABEL_EDIT = wxEVT_FIRST + 703, + wxEVT_COMMAND_LIST_DELETE_ITEM = wxEVT_FIRST + 704, + wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wxEVT_FIRST + 705, + wxEVT_COMMAND_LIST_GET_INFO = wxEVT_FIRST + 706, + wxEVT_COMMAND_LIST_SET_INFO = wxEVT_FIRST + 707, + wxEVT_COMMAND_LIST_ITEM_SELECTED = wxEVT_FIRST + 708, + wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxEVT_FIRST + 709, + wxEVT_COMMAND_LIST_KEY_DOWN = wxEVT_FIRST + 710, + wxEVT_COMMAND_LIST_INSERT_ITEM = wxEVT_FIRST + 711, + wxEVT_COMMAND_LIST_COL_CLICK = wxEVT_FIRST + 712, + wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713, + wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714, + wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxEVT_FIRST + 715, + + /* Tab and notebook control event types */ + wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800, + wxEVT_COMMAND_TAB_SEL_CHANGING = wxEVT_FIRST + 801, + wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxEVT_FIRST + 802, + wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxEVT_FIRST + 803, + + /* Splitter events */ + wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED = wxEVT_FIRST + 850, + wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING = wxEVT_FIRST + 851, + wxEVT_COMMAND_SPLITTER_DOUBLECLICKED = wxEVT_FIRST + 852, + wxEVT_COMMAND_SPLITTER_UNSPLIT = wxEVT_FIRST + 853, + + /* Wizard events */ + wxEVT_WIZARD_PAGE_CHANGED = wxEVT_FIRST + 900, + wxEVT_WIZARD_PAGE_CHANGING = wxEVT_FIRST + 901, + wxEVT_WIZARD_CANCEL = wxEVT_FIRST + 902, + + /* Calendar events */ + wxEVT_CALENDAR_SEL_CHANGED = wxEVT_FIRST + 950, + wxEVT_CALENDAR_DAY_CHANGED = wxEVT_FIRST + 951, + wxEVT_CALENDAR_MONTH_CHANGED = wxEVT_FIRST + 952, + wxEVT_CALENDAR_YEAR_CHANGED = wxEVT_FIRST + 953, + wxEVT_CALENDAR_DOUBLECLICKED = wxEVT_FIRST + 954, + wxEVT_CALENDAR_WEEKDAY_CLICKED = wxEVT_FIRST + 955, + + wxEVT_USER_FIRST = wxEVT_FIRST + 2000 +}; /* Compatibility */ @@ -704,9 +444,12 @@ public: wxNotifyEvent(wxEventType commandType = wxEVT_NULL, int id = 0) : wxCommandEvent(commandType, id) { m_bAllow = TRUE; } - // veto the operation (by default it's allowed) + // veto the operation (usually it's allowed by default) void Veto() { m_bAllow = FALSE; } + // allow the operation if it was disabled by default + void Allow() { m_bAllow = TRUE; } + // for implementation code only: is the operation allowed? bool IsAllowed() const { return m_bAllow; } diff --git a/include/wx/msw/dragimag.h b/include/wx/msw/dragimag.h index a7a1fd0988..ac37bff488 100644 --- a/include/wx/msw/dragimag.h +++ b/include/wx/msw/dragimag.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: dragimag.h +// Name: wx/msw/dragimag.h // Purpose: wxDragImage class: a kind of a cursor, that can cope // with more sophisticated images // Author: Julian Smart @@ -7,7 +7,7 @@ // Created: 08/04/99 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DRAGIMAG_H_ @@ -100,9 +100,8 @@ class WXDLLEXPORT wxDragImage: public wxObject { - DECLARE_DYNAMIC_CLASS(wxDragImage) public: - + // Ctors & dtor //////////////////////////////////////////////////////////////////////////// @@ -133,19 +132,19 @@ public: Create(listCtrl, id); } ~wxDragImage(); - + // Attributes //////////////////////////////////////////////////////////////////////////// - + // Operations //////////////////////////////////////////////////////////////////////////// - + // Create a drag image from a bitmap and optional cursor bool Create(const wxBitmap& image, const wxCursor& cursor = wxNullCursor, const wxPoint& hotspot = wxPoint(0, 0)); - + // Create a drag image from an icon and optional cursor bool Create(const wxIcon& image, const wxCursor& cursor = wxNullCursor, const wxPoint& hotspot = wxPoint(0, 0)); - + // Create a drag image from a string and optional cursor bool Create(const wxString& str, const wxCursor& cursor = wxNullCursor, const wxPoint& hotspot = wxPoint(0, 0)); @@ -158,10 +157,10 @@ public: // Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. bool BeginDrag(const wxPoint& hotspot, wxWindow* window); - + // End drag bool EndDrag(wxWindow* window); - + // Move the image: call from OnMouseMove. Pt is in window client coordinates if window // is non-NULL, or in screen coordinates if NULL. bool Move(const wxPoint& pt, wxWindow* window); @@ -171,18 +170,21 @@ public: // Hide the image bool Hide(wxWindow* window); - + // Implementation //////////////////////////////////////////////////////////////////////////// - + // Returns the native image list handle - inline WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; } - + WXHIMAGELIST GetHIMAGELIST() const { return m_hImageList; } + protected: WXHIMAGELIST m_hImageList; wxCursor m_cursor; wxPoint m_hotspot; wxPoint m_position; + +private: + DECLARE_DYNAMIC_CLASS(wxDragImage) }; #endif diff --git a/include/wx/msw/registry.h b/include/wx/msw/registry.h index c08a75110a..1161e2a285 100644 --- a/include/wx/msw/registry.h +++ b/include/wx/msw/registry.h @@ -2,7 +2,7 @@ // Name: msw/registry.h // Purpose: Registry classes and functions // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 03.04.198 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -56,7 +56,8 @@ public: // (with environment variable references) Type_Binary, // Free form binary Type_Dword, // 32-bit number - Type_Dword_little_endian, // 32-bit number (same as Type_DWORD) + Type_Dword_little_endian // 32-bit number + = Type_Dword, // (same as Type_DWORD) Type_Dword_big_endian, // 32-bit number Type_Link, // Symbolic Link (unicode) Type_Multi_String, // Multiple Unicode strings @@ -69,15 +70,17 @@ public: // predefined registry keys enum StdKey { - HKCR // classes root + HKCR // classes root #ifdef __WIN32__ - , HKCU, // current user - HKLM, // local machine - HKUSR, // users - HKPD // performance data (@@ NT only?) -#if WINVER >= 0x0400 - , HKCC, // current config - HKDD // dynamic data + , + HKCU, // current user + HKLM, // local machine + HKUSR, // users + HKPD // performance data (WinNT/2K only) +#if WINVER >= 0x0400 + , + HKCC, // current config (starting from Win95/NT 4.0) + HKDD // dynamic data (Win95/98 only) #endif // Winver #endif // Win32/16 }; @@ -124,18 +127,10 @@ public: // return true if the key exists bool Exists() const; // get the info about key (any number of these pointers may be NULL) - -#if defined( __GNUWIN32_OLD__ ) bool GetKeyInfo(size_t *pnSubKeys, // number of subkeys size_t *pnMaxKeyLen, // max len of subkey name size_t *pnValues, // number of values size_t *pnMaxValueLen) const; -#else - bool GetKeyInfo(ulong *pnSubKeys, // number of subkeys - ulong *pnMaxKeyLen, // max len of subkey name - ulong *pnValues, // number of values - ulong *pnMaxValueLen) const; -#endif // return true if the key is opened bool IsOpened() const { return m_hKey != 0; } // for "if ( !key ) wxLogError(...)" kind of expressions @@ -145,8 +140,18 @@ public: // explicitly open the key (will be automatically done by all functions // which need the key to be opened if the key is not opened yet) bool Open(); - // create the key: will fail if the key already exists and bOkIfExists + // create the key: will fail if the key already exists and !bOkIfExists bool Create(bool bOkIfExists = TRUE); + // rename a value from old name to new one + bool RenameValue(const wxChar *szValueOld, const wxChar *szValueNew); + // copy value to another key possibly changing its name (by default it will + // remain the same) + bool CopyValue(const wxChar *szValue, wxRegKey& keyDst, + const wxChar *szNewName = NULL); + // copy the entire contents of the key recursively to another location + bool Copy(const wxString& strNewName); + // same as Copy() but using a key and not the name + bool Copy(wxRegKey& keyDst); // close the key (will be automatically done in dtor) bool Close(); diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h index a3b3a95cf8..f27f7bea4b 100644 --- a/include/wx/msw/treectrl.h +++ b/include/wx/msw/treectrl.h @@ -34,6 +34,7 @@ typedef long wxDataType; // fwd decl class WXDLLEXPORT wxImageList; +class WXDLLEXPORT wxDragImage; struct WXDLLEXPORT wxTreeViewItem; // a callback function used for sorting tree items, it should return -1 if the @@ -439,6 +440,7 @@ public: // implementation // -------------- + virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result); @@ -498,6 +500,9 @@ private: // TRUE if the hash above is not empty bool m_hasAnyAttr; + // used for dragging + wxDragImage *m_dragImage; + DECLARE_DYNAMIC_CLASS(wxTreeCtrl) }; diff --git a/include/wx/treectrl.h b/include/wx/treectrl.h index 4c37eb0877..278ea204f8 100644 --- a/include/wx/treectrl.h +++ b/include/wx/treectrl.h @@ -149,7 +149,7 @@ public: const wxString& GetLabel() const { return m_label; } private: - // TODO we could save some space by using union here + // we could probably save some space by using union here int m_code; wxTreeItemId m_item, m_itemOld; @@ -166,9 +166,16 @@ typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&); // ---------------------------------------------------------------------------- // GetItem() returns the item being dragged, GetPoint() the mouse coords +// +// if you call event.Allow(), the drag operation will start and a +// EVT_TREE_END_DRAG event will be sent when the drag is over. #define EVT_TREE_BEGIN_DRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, #define EVT_TREE_BEGIN_RDRAG(id, fn) { wxEVT_COMMAND_TREE_BEGIN_RDRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, +// GetItem() is the item on which the drop occured (if any) and GetPoint() the +// current mouse coords +#define EVT_TREE_END_DRAG(id, fn) { wxEVT_COMMAND_TREE_END_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, + // GetItem() returns the itme whose label is being edited, GetLabel() returns // the current item label for BEGIN and the would be new one for END. // diff --git a/samples/regtest/regtest.cpp b/samples/regtest/regtest.cpp index 6a0ce41c81..3717bed45e 100644 --- a/samples/regtest/regtest.cpp +++ b/samples/regtest/regtest.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: registry.cpp +// Name: regtest.cpp // Purpose: wxRegKey class demo // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 03.04.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -35,9 +35,9 @@ // application type // ---------------------------------------------------------------------------- class RegApp : public wxApp -{ +{ public: - bool OnInit(void); + bool OnInit(); }; // ---------------------------------------------------------------------------- @@ -58,9 +58,6 @@ public: RegImageList(); }; -// array of children of the node -//class TreeNode; - // ---------------------------------------------------------------------------- // our control // ---------------------------------------------------------------------------- @@ -76,14 +73,19 @@ public: void OnItemExpanding(wxTreeEvent& event); void OnSelChanged (wxTreeEvent& event); + void OnBeginDrag (wxTreeEvent& event); + void OnEndDrag (wxTreeEvent& event); + void OnRightClick (wxMouseEvent& event); void OnChar (wxKeyEvent& event); + void OnIdle (wxIdleEvent& event); // forwarded notifications (by the frame) void OnMenuTest(); // operations void DeleteSelected(); + void ShowProperties(); void CreateNewKey(const wxString& strName); void CreateNewTextValue(const wxString& strName); void CreateNewBinaryValue(const wxString& strName); @@ -91,77 +93,79 @@ public: // information bool IsKeySelected() const; - DECLARE_EVENT_TABLE(); - private: - // structure describing a registry key/value - class TreeNode : public wxTreeItemData + class TreeNode : public wxTreeItemData { -WX_DEFINE_ARRAY(TreeNode *, TreeChildren); + WX_DEFINE_ARRAY(TreeNode *, TreeChildren); public: - RegTreeCtrl *m_pTree; // must be !NULL - TreeNode *m_pParent; // NULL only for the root node - long m_id; // the id of the tree control item - wxString m_strName; // name of the key/value - TreeChildren m_aChildren; // array of subkeys/values - bool m_bKey; // key or value? - wxRegKey *m_pKey; // only may be !NULL if m_bKey == true - long m_lDummy; // dummy subkey (to make expansion possible) - - // ctor - TreeNode() { m_lDummy = 0; } - - // trivial accessors - long Id() const { return m_id; } - bool IsRoot() const { return m_pParent == NULL; } - bool IsKey() const { return m_bKey; } - TreeNode *Parent() const { return m_pParent; } - - // notifications - bool OnExpand(); - void OnCollapse(); - - // operations - void Refresh() { OnCollapse(); OnExpand(); } - void AddDummy(); - void DestroyChildren(); - const char *FullName() const; - - // get the associated key: make sure the pointer is !NULL - wxRegKey& Key() { if ( !m_pKey ) OnExpand(); return *m_pKey; } - - // dtor deletes all children - ~TreeNode(); + RegTreeCtrl *m_pTree; // must be !NULL + TreeNode *m_pParent; // NULL only for the root node + long m_id; // the id of the tree control item + wxString m_strName; // name of the key/value + TreeChildren m_aChildren; // array of subkeys/values + bool m_bKey; // key or value? + wxRegKey *m_pKey; // only may be !NULL if m_bKey == true + + // trivial accessors + long Id() const { return m_id; } + bool IsRoot() const { return m_pParent == NULL; } + bool IsKey() const { return m_bKey; } + TreeNode *Parent() const { return m_pParent; } + + // notifications + bool OnExpand(); + void OnCollapse(); + + // operations + void Refresh(); + bool DeleteChild(TreeNode *child); + void DestroyChildren(); + const char *FullName() const; + + // get the associated key: make sure the pointer is !NULL + wxRegKey& Key() { if ( !m_pKey ) OnExpand(); return *m_pKey; } + + // dtor deletes all children + ~TreeNode(); }; + wxImageList *m_imageList; wxMenu *m_pMenuPopup; + TreeNode *m_pRoot; - wxImageList *m_imageList; + + TreeNode *m_draggedItem; // the item being dragged + bool m_copyOnDrop; // if FALSE, then move + + bool m_restoreStatus; // after OnItemExpanding() TreeNode *GetNode(const wxTreeEvent& event) { return (TreeNode *)GetItemData((WXHTREEITEM)event.GetItem()); } public: // create a new node and insert it to the tree - TreeNode *InsertNewTreeNode(TreeNode *pParent, + TreeNode *InsertNewTreeNode(TreeNode *pParent, const wxString& strName, int idImage = RegImageList::ClosedKey, const wxString *pstrValue = NULL); // add standard registry keys void AddStdKeys(); + +private: + DECLARE_EVENT_TABLE(); }; // ---------------------------------------------------------------------------- // the main window of our application // ---------------------------------------------------------------------------- class RegFrame : public wxFrame -{ +{ public: // ctor & dtor RegFrame(wxFrame *parent, char *title, int x, int y, int w, int h); - virtual ~RegFrame(void); - + virtual ~RegFrame(); + // callbacks void OnQuit (wxCommandEvent& event); void OnAbout(wxCommandEvent& event); @@ -176,7 +180,7 @@ public: void OnNewText (wxCommandEvent& event); void OnNewBinary(wxCommandEvent& event); - bool OnClose () { return TRUE; } + void OnInfo (wxCommandEvent& event); DECLARE_EVENT_TABLE(); @@ -197,10 +201,11 @@ enum Menu_Collapse, Menu_Toggle, Menu_New, - Menu_NewKey, - Menu_NewText, + Menu_NewKey, + Menu_NewText, Menu_NewBinary, Menu_Delete, + Menu_Info, Ctrl_RegTree = 200, }; @@ -220,15 +225,20 @@ BEGIN_EVENT_TABLE(RegFrame, wxFrame) EVT_MENU(Menu_NewKey, RegFrame::OnNewKey) EVT_MENU(Menu_NewText, RegFrame::OnNewText) EVT_MENU(Menu_NewBinary,RegFrame::OnNewBinary) + EVT_MENU(Menu_Info, RegFrame::OnInfo) END_EVENT_TABLE() BEGIN_EVENT_TABLE(RegTreeCtrl, wxTreeCtrl) EVT_TREE_DELETE_ITEM (Ctrl_RegTree, RegTreeCtrl::OnDeleteItem) EVT_TREE_ITEM_EXPANDING(Ctrl_RegTree, RegTreeCtrl::OnItemExpanding) EVT_TREE_SEL_CHANGED (Ctrl_RegTree, RegTreeCtrl::OnSelChanged) + EVT_TREE_BEGIN_DRAG (Ctrl_RegTree, RegTreeCtrl::OnBeginDrag) + EVT_TREE_BEGIN_RDRAG (Ctrl_RegTree, RegTreeCtrl::OnBeginDrag) + EVT_TREE_END_DRAG (Ctrl_RegTree, RegTreeCtrl::OnEndDrag) EVT_CHAR (RegTreeCtrl::OnChar) EVT_RIGHT_DOWN(RegTreeCtrl::OnRightClick) + EVT_IDLE (RegTreeCtrl::OnIdle) END_EVENT_TABLE() // ============================================================================ @@ -255,6 +265,8 @@ wxMenu *CreateRegistryMenu() pMenuReg->Append(Menu_Expand, "&Expand", "Expand current key"); pMenuReg->Append(Menu_Collapse, "&Collapse", "Collapse current key"); pMenuReg->Append(Menu_Toggle, "&Toggle", "Toggle current key"); + pMenuReg->AppendSeparator(); + pMenuReg->Append(Menu_Info, "&Properties","Information about current selection"); return pMenuReg; } @@ -268,9 +280,9 @@ IMPLEMENT_APP(RegApp) bool RegApp::OnInit() { // create the main frame window and show it - RegFrame *frame = new RegFrame(NULL, "wxRegKey Test", 50, 50, 600, 350); + RegFrame *frame = new RegFrame(NULL, "wxRegTest", 50, 50, 600, 350); frame->Show(TRUE); - + SetTopWindow(frame); return TRUE; @@ -317,8 +329,10 @@ RegFrame::RegFrame(wxFrame *parent, char *title, int x, int y, int w, int h) SetStatusWidths(2, aWidths); } -RegFrame::~RegFrame(void) +RegFrame::~RegFrame() { + // this makes deletion of it *much* quicker + m_treeCtrl->Hide(); } void RegFrame::OnQuit(wxCommandEvent& event) @@ -328,8 +342,10 @@ void RegFrame::OnQuit(wxCommandEvent& event) void RegFrame::OnAbout(wxCommandEvent& event) { - wxMessageDialog dialog(this, "wxRegistry sample\n(c) 1998 Vadim Zeitlin", - "About wxRegistry", wxOK); + wxMessageDialog dialog(this, + "wxRegistry sample\n" + "© 1998, 2000 Vadim Zeitlin", + "About wxRegTest", wxOK); dialog.ShowModal(); } @@ -383,6 +399,11 @@ void RegFrame::OnNewBinary(wxCommandEvent& event) } } +void RegFrame::OnInfo(wxCommandEvent& event) +{ + m_treeCtrl->ShowProperties(); +} + // ---------------------------------------------------------------------------- // RegImageList // ---------------------------------------------------------------------------- @@ -401,7 +422,7 @@ RegImageList::RegImageList() : wxImageList(16, 16, TRUE) // ---------------------------------------------------------------------------- // create a new tree item and insert it into the tree -RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent, +RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent, const wxString& strName, int idImage, const wxString *pstrValue) @@ -413,7 +434,7 @@ RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent, pNewNode->m_strName = strName; pNewNode->m_bKey = pstrValue == NULL; pNewNode->m_pKey = NULL; - pNewNode->m_id = InsertItem(pParent ? pParent->m_id : 0, + pNewNode->m_id = InsertItem(pParent ? pParent->Id() : 0, pNewNode->IsKey() ? strName : *pstrValue, idImage); @@ -427,17 +448,28 @@ RegTreeCtrl::TreeNode *RegTreeCtrl::InsertNewTreeNode(TreeNode *pParent, pParent->m_aChildren.Add(pNewNode); } - // force the [+] button (@@@ not very elegant...) - if ( pNewNode->IsKey() ) - pNewNode->AddDummy(); + if ( pNewNode->IsKey() ) { + SetItemHasChildren(pNewNode->Id()); + + if ( !pNewNode->IsRoot() ) { + // set the expanded icon as well + SetItemImage(pNewNode->Id(), + RegImageList::OpenedKey, + wxTreeItemIcon_Expanded); + } + } return pNewNode; } RegTreeCtrl::RegTreeCtrl(wxWindow *parent, wxWindowID id) - : wxTreeCtrl(parent, id, wxDefaultPosition, wxDefaultSize, + : wxTreeCtrl(parent, id, wxDefaultPosition, wxDefaultSize, wxTR_HAS_BUTTONS | wxSUNKEN_BORDER) { + // init members + m_draggedItem = NULL; + m_restoreStatus = FALSE; + // create the image list // --------------------- m_imageList = new RegImageList; @@ -455,7 +487,7 @@ RegTreeCtrl::RegTreeCtrl(wxWindow *parent, wxWindowID id) RegTreeCtrl::~RegTreeCtrl() { delete m_pMenuPopup; - delete m_pRoot; + // delete m_pRoot; -- this is done by the tree now delete m_imageList; } @@ -470,16 +502,30 @@ void RegTreeCtrl::AddStdKeys() // notifications // ---------------------------------------------------------------------------- +void RegTreeCtrl::OnIdle(wxIdleEvent& WXUNUSED(event)) +{ + if ( m_restoreStatus ) { + // restore it after OnItemExpanding() + wxLogStatus("Ok"); + wxSetCursor(*wxSTANDARD_CURSOR); + + m_restoreStatus = FALSE; + } +} + void RegTreeCtrl::OnRightClick(wxMouseEvent& event) { int iFlags; long lId = HitTest(wxPoint(event.GetX(), event.GetY()), iFlags); - if ( iFlags & wxTREE_HITTEST_ONITEMLABEL ) { - // popup menu only if an item was clicked - wxASSERT( lId != 0 ); + if ( !(iFlags & wxTREE_HITTEST_ONITEMLABEL) ) { + // take the currently selected item if click not on item + lId = GetSelection(); + } + else { SelectItem(lId); - PopupMenu(m_pMenuPopup, event.GetX(), event.GetY()); } + + PopupMenu(m_pMenuPopup, event.GetX(), event.GetY()); } @@ -520,16 +566,28 @@ void RegTreeCtrl::OnMenuTest() return; } } - + wxLogError("Creation of test keys failed."); } void RegTreeCtrl::OnChar(wxKeyEvent& event) { - if ( event.KeyCode() == WXK_DELETE ) - DeleteSelected(); - else - event.Skip(); + switch ( event.KeyCode() ) + { + case WXK_DELETE: + DeleteSelected(); + return; + + case WXK_RETURN: + if ( event.AltDown() ) + { + ShowProperties(); + + return; + } + } + + event.Skip(); } void RegTreeCtrl::OnSelChanged(wxTreeEvent& event) @@ -547,6 +605,7 @@ void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event) wxSetCursor(*wxHOURGLASS_CURSOR); wxLogStatus("Working..."); wxYield(); // to give the status line a chance to refresh itself + m_restoreStatus = TRUE; // some time later... if ( pNode->IsKey() ) { if ( bExpanding ) { @@ -558,17 +617,116 @@ void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event) // collapsing: clean up pNode->OnCollapse(); } + } +} + +void RegTreeCtrl::OnBeginDrag(wxTreeEvent& event) +{ + m_copyOnDrop = event.GetEventType() == wxEVT_COMMAND_TREE_BEGIN_DRAG; + + TreeNode *pNode = GetNode(event); + if ( pNode->IsRoot() || pNode->Parent()->IsRoot() ) + { + wxLogStatus("This registry key can't be %s.", + m_copyOnDrop ? "copied" : "moved"); + } + else + { + wxLogStatus("%s item %s...", + m_copyOnDrop ? "Copying" : "Moving", + pNode->FullName()); - // change icon for non root key - if ( !pNode->IsRoot() ) { - int idIcon = bExpanding ? RegImageList::OpenedKey - : RegImageList::ClosedKey; - SetItemImage(pNode->Id(), idIcon); + m_draggedItem = pNode; + + event.Allow(); + } +} + +void RegTreeCtrl::OnEndDrag(wxTreeEvent& event) +{ + wxCHECK_RET( m_draggedItem, "end drag without begin drag?" ); + + // clear the pointer anyhow + TreeNode *src = m_draggedItem; + m_draggedItem = NULL; + + // where are we going to drop it? + TreeNode *dst = GetNode(event); + if ( dst && !dst->IsKey() ) { + // we need a parent key + dst = dst->Parent(); + } + if ( !dst || dst->IsRoot() ) { + wxLogError("Can't create a key here."); + + return; + } + + bool isKey = src->IsKey(); + if ( (isKey && (src == dst)) || + (!isKey && (src->Parent() == dst)) ) { + wxLogStatus("Can't copy something on itself"); + + return; + } + + // remove the "Registry Root\\" from the full name + wxString nameSrc, nameDst; + nameSrc << wxString(src->FullName()).AfterFirst('\\'); + nameDst << wxString(dst->FullName()).AfterFirst('\\') << '\\' + << wxString(src->FullName()).AfterLast('\\'); + + wxString verb = m_copyOnDrop ? "copy" : "move"; + wxString what = isKey ? "key" : "value"; + + if ( wxMessageBox(wxString::Format + ( + "Do you really want to %s the %s %s to %s?", + verb.c_str(), + what.c_str(), + nameSrc.c_str(), + nameDst.c_str() + ), + "RegTest Confirm", + wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) { + return; + } + + bool dstExpanded = IsExpanded(dst->Id()); + + bool ok; + if ( isKey ) { + wxRegKey& key = src->Key(); + ok = key.Copy(dst->Key()); + if ( ok && dstExpanded ) { + dst->OnCollapse(); + dst->OnExpand(); + } + + if ( ok && !m_copyOnDrop ) { + // delete the old key + ok = key.DeleteSelf(); + if ( ok ) { + src->Parent()->Refresh(); + } + } + } + else { // value + wxRegKey& key = src->Parent()->Key(); + ok = key.CopyValue(src->m_strName, dst->Key()); + if ( ok && !m_copyOnDrop ) { + // we move it, so delete the old one + ok = key.DeleteValue(src->m_strName); + if ( ok ) { + // reexpand the key + dst->Refresh(); + } + } } - } - wxLogStatus("Ok"); - wxSetCursor(*wxSTANDARD_CURSOR); + if ( !ok ) { + wxLogError("Failed to %s registry %s.", verb.c_str(), what.c_str()); + } } // ---------------------------------------------------------------------------- @@ -576,12 +734,8 @@ void RegTreeCtrl::OnItemExpanding(wxTreeEvent& event) // ---------------------------------------------------------------------------- bool RegTreeCtrl::TreeNode::OnExpand() { - // remove dummy item - if ( m_lDummy != 0 ) { - m_pTree->Delete(m_lDummy); - m_lDummy = 0; - } - else { + // we add children only once + if ( !m_aChildren.IsEmpty() ) { // we've been already expanded return TRUE; } @@ -606,6 +760,9 @@ bool RegTreeCtrl::TreeNode::OnExpand() return FALSE; } + // if we're empty, we shouldn't be expandable at all + bool isEmpty = TRUE; + // enumeration variables long l; wxString str; @@ -616,6 +773,9 @@ bool RegTreeCtrl::TreeNode::OnExpand() while ( bCont ) { m_pTree->InsertNewTreeNode(this, str, RegImageList::ClosedKey); bCont = m_pKey->GetNextKey(str, l); + + // we have at least this key... + isEmpty = FALSE; } // enumerate all values @@ -649,11 +809,9 @@ bool RegTreeCtrl::TreeNode::OnExpand() case wxRegKey::Type_Dword: { - char szBuf[128]; long l; m_pKey->QueryValue(str, &l); - sprintf(szBuf, "%lx", l); - strItem += szBuf; + strItem << l; } // fall through @@ -664,6 +822,17 @@ bool RegTreeCtrl::TreeNode::OnExpand() m_pTree->InsertNewTreeNode(this, str, icon, &strItem); bCont = m_pKey->GetNextValue(str, l); + + // we have at least this value... + isEmpty = FALSE; + } + + if ( isEmpty ) { + // this is for the case when our last child was just deleted + m_pTree->Collapse(Id()); + + // we won't be expanded any more + m_pTree->SetItemHasChildren(Id(), FALSE); } return TRUE; @@ -671,30 +840,58 @@ bool RegTreeCtrl::TreeNode::OnExpand() void RegTreeCtrl::TreeNode::OnCollapse() { - bool bHasChildren = !m_aChildren.IsEmpty(); DestroyChildren(); - if ( bHasChildren ) - AddDummy(); - else - m_lDummy = 0; delete m_pKey; m_pKey = NULL; } -void RegTreeCtrl::TreeNode::AddDummy() +void RegTreeCtrl::TreeNode::Refresh() +{ + if ( m_pTree->IsExpanded(Id()) ) + { + m_pTree->Collapse(Id()); + m_pTree->SetItemHasChildren(Id()); + m_pTree->Expand(Id()); + } +} + +bool RegTreeCtrl::TreeNode::DeleteChild(TreeNode *child) { - // insert dummy item forcing appearance of [+] button - m_lDummy = m_pTree->InsertItem(Id(), ""); + int index = m_aChildren.Index(child); + wxCHECK_MSG( index != wxNOT_FOUND, FALSE, + "our child in tree should be in m_aChildren" ); + + m_aChildren.RemoveAt((size_t)index); + + bool ok; + if ( child->IsKey() ) { + // must close key before deleting it + child->OnCollapse(); + + ok = Key().DeleteKey(child->m_strName); + } + else { + ok = Key().DeleteValue(child->m_strName); + } + + if ( ok ) { + m_pTree->Delete(child->Id()); + + Refresh(); + } + + return ok; } void RegTreeCtrl::TreeNode::DestroyChildren() { // destroy all children - unsigned int nCount = m_aChildren.Count(); - for ( unsigned int n = 0; n < nCount; n++ ) { - long lId = m_aChildren[n]->Id(); - delete m_aChildren[n]; + size_t nCount = m_aChildren.GetCount(); + for ( size_t n = 0; n < nCount; n++ ) { + long lId = m_aChildren[n]->Id(); + // no, wxTreeCtrl will do it + //delete m_aChildren[n]; m_pTree->Delete(lId); } @@ -703,8 +900,6 @@ void RegTreeCtrl::TreeNode::DestroyChildren() RegTreeCtrl::TreeNode::~TreeNode() { - DestroyChildren(); - delete m_pKey; } @@ -716,7 +911,7 @@ const char *RegTreeCtrl::TreeNode::FullName() const return "Registry Root"; } else { - // our own registry key might not (yet) exist or we might be a value, + // our own registry key might not (yet) exist or we might be a value, // so just use the parent's and concatenate s_strName = Parent()->FullName(); s_strName << '\\' << m_strName; @@ -749,29 +944,18 @@ void RegTreeCtrl::DeleteSelected() return; } - if ( pCurrent->IsKey() ) { - if ( wxMessageBox("Do you really want to delete this key?", - "Confirmation", - wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) { - return; - } - - // must close key before deleting it - pCurrent->OnCollapse(); - - if ( pParent->Key().DeleteKey(pCurrent->m_strName) ) - pParent->Refresh(); + wxString what = pCurrent->IsKey() ? "key" : "value"; + if ( wxMessageBox(wxString::Format + ( + "Do you really want to delete this %s?", + what.c_str() + ), + "Confirmation", + wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) { + return; } - else { - if ( wxMessageBox("Do you really want to delete this value?", - "Confirmation", - wxICON_QUESTION | wxYES_NO | wxCANCEL, this) != wxYES ) { - return; - } - if ( pParent->Key().DeleteValue(pCurrent->m_strName) ) - pParent->Refresh(); - } + pParent->DeleteChild(pCurrent); } void RegTreeCtrl::CreateNewKey(const wxString& strName) @@ -780,7 +964,7 @@ void RegTreeCtrl::CreateNewKey(const wxString& strName) TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); wxCHECK_RET( pCurrent != NULL, "node without data?" ); - + wxASSERT( pCurrent->IsKey() ); // check must have been done before if ( pCurrent->IsRoot() ) { @@ -799,7 +983,7 @@ void RegTreeCtrl::CreateNewTextValue(const wxString& strName) TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); wxCHECK_RET( pCurrent != NULL, "node without data?" ); - + wxASSERT( pCurrent->IsKey() ); // check must have been done before if ( pCurrent->IsRoot() ) { @@ -817,7 +1001,7 @@ void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName) TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); wxCHECK_RET( pCurrent != NULL, "node without data?" ); - + wxASSERT( pCurrent->IsKey() ); // check must have been done before if ( pCurrent->IsRoot() ) { @@ -829,6 +1013,49 @@ void RegTreeCtrl::CreateNewBinaryValue(const wxString& strName) pCurrent->Refresh(); } +void RegTreeCtrl::ShowProperties() +{ + long lCurrent = GetSelection(); + TreeNode *pCurrent = (TreeNode *)GetItemData(lCurrent); + + if ( !pCurrent || pCurrent->IsRoot() ) + { + wxLogStatus("No properties"); + + return; + } + + if ( pCurrent->IsKey() ) + { + const wxRegKey& key = pCurrent->Key(); + size_t nSubKeys, nValues; + if ( !key.GetKeyInfo(&nSubKeys, NULL, &nValues, NULL) ) + { + wxLogError("Couldn't get key info"); + } + else + { + wxLogMessage("Key '%s' has %u subkeys and %u values.", + key.GetName().c_str(), nSubKeys, nValues); + } + } + else // it's a value + { + TreeNode *parent = pCurrent->Parent(); + wxCHECK_RET( parent, "reg value without key?" ); + + const wxRegKey& key = parent->Key(); + const char *value = pCurrent->m_strName.c_str(); + wxLogMessage("Value '%s' under the key '%s' is of type " + "%d (%s).", + value, + parent->m_strName.c_str(), + key.GetValueType(value), + key.IsNumericValue(value) ? "numeric" : "string"); + + } +} + bool RegTreeCtrl::IsKeySelected() const { long lCurrent = GetSelection(); @@ -837,4 +1064,4 @@ bool RegTreeCtrl::IsKeySelected() const wxCHECK( pCurrent != NULL, FALSE ); return pCurrent->IsKey(); -} \ No newline at end of file +} diff --git a/src/common/db.cpp b/src/common/db.cpp index 02c1ab48f7..d2b7427acf 100644 --- a/src/common/db.cpp +++ b/src/common/db.cpp @@ -5,7 +5,7 @@ // source such as opening and closing the data source. // Author: Doug Card // Modified by: George Tasker -// Mods: Dec, 1998: +// Mods: Dec, 1998: // -Added support for SQL statement logging and database cataloging // Mods: April, 1999 // -Added QUERY_ONLY mode support to reduce default number of cursors @@ -111,7 +111,7 @@ char *SQLLOGfn = (char*) SQL_LOG_FILENAME; // database object is closed. This is necessary if the database // connection fails so the calling application can show the operator // why the connection failed. Note: as each wxDB object is closed, it -// will overwrite the errors of the previously destroyed wxDB object in +// will overwrite the errors of the previously destroyed wxDB object in // this variable. char DBerrorList[DB_MAX_ERROR_HISTORY][DB_MAX_ERROR_MSG_LEN]; @@ -225,7 +225,7 @@ wxDB::wxDB(HENV &aHenv, bool FwdOnlyCursors) fpSqlLog = 0; // Sql Log file pointer sqlLogState = sqlLogOFF; // By default, logging is turned off nTables = 0; - + wxStrcpy(sqlState,""); wxStrcpy(errorMsg,""); nativeError = cbErrorMsg = 0; @@ -256,10 +256,10 @@ wxDB::wxDB(HENV &aHenv, bool FwdOnlyCursors) typeInfDate.Precision = 0; typeInfDate.CaseSensitive = 0; typeInfDate.MaximumScale = 0; - + // Error reporting is turned OFF by default silent = TRUE; - + // Copy the HENV into the db class henv = aHenv; fwdOnlyCursors = FwdOnlyCursors; @@ -454,12 +454,12 @@ bool wxDB::setConnectionOptions(void) // Display the connection options to verify them #ifdef DBDEBUG_CONSOLE long l; - cout << ">>>>> CONNECTION OPTIONS <<<<<<" << endl; - + cout << "****** CONNECTION OPTIONS ******" << endl; + if (SQLGetConnectOption(hdbc, SQL_AUTOCOMMIT, &l) != SQL_SUCCESS) return(DispAllErrors(henv, hdbc)); cout << "AUTOCOMMIT: " << (l == SQL_AUTOCOMMIT_OFF ? "OFF" : "ON") << endl; - + if (SQLGetConnectOption(hdbc, SQL_ODBC_CURSORS, &l) != SQL_SUCCESS) return(DispAllErrors(henv, hdbc)); cout << "ODBC CURSORS: "; @@ -476,7 +476,7 @@ bool wxDB::setConnectionOptions(void) break; } cout << endl; - + if (SQLGetConnectOption(hdbc, SQL_OPT_TRACE, &l) != SQL_SUCCESS) return(DispAllErrors(henv, hdbc)); cout << "TRACING: " << (l == SQL_OPT_TRACE_OFF ? "OFF" : "ON") << endl; @@ -593,7 +593,7 @@ bool wxDB::getDbInfo(void) return(DispAllErrors(henv, hdbc)); #ifdef DBDEBUG_CONSOLE - cout << ">>>>> DATA SOURCE INFORMATION <<<<<" << endl; + cout << "***** DATA SOURCE INFORMATION *****" << endl; cout << "SERVER Name: " << dbInf.serverName << endl; cout << "DBMS Name: " << dbInf.dbmsName << "; DBMS Version: " << dbInf.dbmsVer << endl; cout << "ODBC Version: " << dbInf.odbcVer << "; Driver Version: " << dbInf.driverVer << endl; @@ -1218,7 +1218,7 @@ int wxDB::TranslateSqlState(const char *SQLState) } // wxDB::TranslateSqlState() - + /********** wxDB::Grant() **********/ bool wxDB::Grant(int privileges, const char *tableName, const char *userList) { @@ -1286,7 +1286,7 @@ bool wxDB::CreateView(const char *viewName, const char *colList, const char *pSq // Build the create view statement sqlStmt = "CREATE VIEW "; sqlStmt += viewName; - + if (wxStrlen(colList)) { sqlStmt += " ("; @@ -1560,7 +1560,7 @@ wxColInf *wxDB::GetColumns(char *tableName[], const char *userID) * userID != "" ... UserID set equal to 'userID' * * NOTE: ALL column bindings associated with this wxDB instance are unbound - * by this function. This function should use its own wxDB instance + * by this function. This function should use its own wxDB instance * to avoid undesired unbinding of columns. */ { @@ -1588,7 +1588,7 @@ wxColInf *wxDB::GetColumns(char *tableName[], const char *userID) if (Dbms() == dbmsDBASE) UserID = ""; - // Oracle user names may only be in uppercase, so force + // Oracle user names may only be in uppercase, so force // the name to uppercase if (Dbms() == dbmsORACLE) UserID = UserID.Upper(); @@ -1617,7 +1617,7 @@ wxColInf *wxDB::GetColumns(char *tableName[], const char *userID) for (tbl = 0; tableName[tbl]; tbl++) { TableName = tableName[tbl]; - // Oracle table names are uppercase only, so force + // Oracle table names are uppercase only, so force // the name to uppercase just in case programmer forgot to do this if (Dbms() == dbmsORACLE) TableName = TableName.Upper(); @@ -1720,7 +1720,7 @@ wxColInf *wxDB::GetColumns(char *tableName, int *numCols, const char *userID) * userID != "" ... UserID set equal to 'userID' * * NOTE: ALL column bindings associated with this wxDB instance are unbound - * by this function. This function should use its own wxDB instance + * by this function. This function should use its own wxDB instance * to avoid undesired unbinding of columns. */ { @@ -1748,7 +1748,7 @@ wxColInf *wxDB::GetColumns(char *tableName, int *numCols, const char *userID) if (Dbms() == dbmsDBASE) UserID = ""; - // Oracle user names may only be in uppercase, so force + // Oracle user names may only be in uppercase, so force // the name to uppercase if (Dbms() == dbmsORACLE) UserID = UserID.Upper(); @@ -1774,7 +1774,7 @@ wxColInf *wxDB::GetColumns(char *tableName, int *numCols, const char *userID) } TableName = tableName; - // Oracle table names are uppercase only, so force + // Oracle table names are uppercase only, so force // the name to uppercase just in case programmer forgot to do this if (Dbms() == dbmsORACLE) TableName = TableName.Upper(); @@ -1829,7 +1829,7 @@ wxColInf *wxDB::GetColumns(char *tableName, int *numCols, const char *userID) GetData( 6, SQL_C_CHAR, (UCHAR*) colInf[colNo].typeName, 128+1, &cb); GetData( 7, SQL_C_SLONG, (UCHAR*) &colInf[colNo].columnSize, 0, &cb); // BJO 991214 : SQL_C_SSHORT instead of SQL_C_SLONG, otherwise fails on Sparc (probably all 64 bit architectures) - GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferLength, 0, &cb); + GetData( 8, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].bufferLength, 0, &cb); GetData( 9, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].decimalDigits,0, &cb); GetData(10, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].numPrecRadix, 0, &cb); GetData(11, SQL_C_SSHORT, (UCHAR*) &colInf[colNo].nullable, 0, &cb); @@ -1892,7 +1892,7 @@ int wxDB::GetColumnCount(char *tableName, const char *userID) * userID != "" ... UserID set equal to 'userID' * * NOTE: ALL column bindings associated with this wxDB instance are unbound - * by this function. This function should use its own wxDB instance + * by this function. This function should use its own wxDB instance * to avoid undesired unbinding of columns. */ { @@ -1917,7 +1917,7 @@ int wxDB::GetColumnCount(char *tableName, const char *userID) if (Dbms() == dbmsDBASE) UserID = ""; - // Oracle user names may only be in uppercase, so force + // Oracle user names may only be in uppercase, so force // the name to uppercase if (Dbms() == dbmsORACLE) UserID = UserID.Upper(); @@ -1926,7 +1926,7 @@ int wxDB::GetColumnCount(char *tableName, const char *userID) // Loop through each table name { TableName = tableName; - // Oracle table names are uppercase only, so force + // Oracle table names are uppercase only, so force // the name to uppercase just in case programmer forgot to do this if (Dbms() == dbmsORACLE) TableName = TableName.Upper(); @@ -1999,7 +1999,7 @@ wxDbInf *wxDB::GetCatalog(char *userID) * userID != "" ... UserID set equal to 'userID' * * NOTE: ALL column bindings associated with this wxDB instance are unbound - * by this function. This function should use its own wxDB instance + * by this function. This function should use its own wxDB instance * to avoid undesired unbinding of columns. */ { @@ -2027,7 +2027,7 @@ wxDbInf *wxDB::GetCatalog(char *userID) if (Dbms() == dbmsDBASE) UserID = ""; - // Oracle user names may only be in uppercase, so force + // Oracle user names may only be in uppercase, so force // the name to uppercase if (Dbms() == dbmsORACLE) UserID = UserID.Upper(); @@ -2132,7 +2132,7 @@ bool wxDB::Catalog(const char *userID, const char *fileName) * userID != "" ... UserID set equal to 'userID' * * NOTE: ALL column bindings associated with this wxDB instance are unbound - * by this function. This function should use its own wxDB instance + * by this function. This function should use its own wxDB instance * to avoid undesired unbinding of columns. */ { @@ -2169,7 +2169,7 @@ bool wxDB::Catalog(const char *userID, const char *fileName) if (Dbms() == dbmsDBASE) UserID = ""; - // Oracle user names may only be in uppercase, so force + // Oracle user names may only be in uppercase, so force // the name to uppercase if (Dbms() == dbmsORACLE) UserID = UserID.Upper(); @@ -2295,13 +2295,13 @@ bool wxDB::TableExists(const char *tableName, const char *userID, const char *ta else UserID = ""; - // Oracle user names may only be in uppercase, so force + // Oracle user names may only be in uppercase, so force // the name to uppercase if (Dbms() == dbmsORACLE) UserID = UserID.Upper(); TableName = tableName; - // Oracle table names are uppercase only, so force + // Oracle table names are uppercase only, so force // the name to uppercase just in case programmer forgot to do this if (Dbms() == dbmsORACLE) TableName = TableName.Upper(); @@ -2434,7 +2434,7 @@ DBMS wxDB::Dbms(void) * - Cannot support selecting for update [::CanSelectForUpdate()]. Always returns FALSE * * POSTGRES - * - Does not support the keywords 'ASC' or 'DESC' as of release v6.5.0 + * - Does not support the keywords 'ASC' or 'DESC' as of release v6.5.0 * * */ @@ -2444,7 +2444,7 @@ DBMS wxDB::Dbms(void) wxStrncpy(baseName,dbInf.dbmsName,25); if (!wxStricmp(dbInf.dbmsName,"Adaptive Server Anywhere")) return(dbmsSYBASE_ASA); - if (!wxStricmp(dbInf.dbmsName,"SQL Server")) // Sybase Adaptive Server + if (!wxStricmp(dbInf.dbmsName,"SQL Server")) // Sybase Adaptive Server return(dbmsSYBASE_ASE); if (!wxStricmp(dbInf.dbmsName,"Microsoft SQL Server")) return(dbmsMS_SQL_SERVER); @@ -2559,7 +2559,7 @@ bool WXDLLEXPORT FreeDbConnection(wxDB *pDb) void WXDLLEXPORT CloseDbConnections(void) { DbList *pList, *pNext; - + // Traverse the linked list closing database connections and freeing memory as I go. for (pList = PtrBegDbList; pList; pList = pNext) { diff --git a/src/common/event.cpp b/src/common/event.cpp index 439445a36f..8843bd11c8 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -46,268 +46,52 @@ #include "wx/validate.h" #endif // wxUSE_GUI - -#if defined(__VISAGECPP__) && __IBMCPP__ >= 400 -// must define these static for VA or else you get multiply defined symbols everywhere -const wxEventType wxEVT_NULL = 0; -const wxEventType wxEVT_FIRST = 10000; - -const wxEventType wxEVT_COMMAND_BUTTON_CLICKED = wxEVT_FIRST + 1; -const wxEventType wxEVT_COMMAND_CHECKBOX_CLICKED = wxEVT_FIRST + 2; -const wxEventType wxEVT_COMMAND_CHOICE_SELECTED = wxEVT_FIRST + 3; -const wxEventType wxEVT_COMMAND_LISTBOX_SELECTED = wxEVT_FIRST + 4; -const wxEventType wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxEVT_FIRST + 5; -const wxEventType wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxEVT_FIRST + 6; -const wxEventType wxEVT_COMMAND_TEXT_UPDATED = wxEVT_FIRST + 7; -const wxEventType wxEVT_COMMAND_TEXT_ENTER = wxEVT_FIRST + 8; -const wxEventType wxEVT_COMMAND_MENU_SELECTED = wxEVT_FIRST + 9; -const wxEventType wxEVT_COMMAND_TOOL_CLICKED = wxEVT_COMMAND_MENU_SELECTED; -const wxEventType wxEVT_COMMAND_SLIDER_UPDATED = wxEVT_FIRST + 10; -const wxEventType wxEVT_COMMAND_RADIOBOX_SELECTED = wxEVT_FIRST + 11; -const wxEventType wxEVT_COMMAND_RADIOBUTTON_SELECTED = wxEVT_FIRST + 12; -//const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED is now obsolete since we use wxEVT_SCROLL... events -const wxEventType wxEVT_COMMAND_SCROLLBAR_UPDATED = wxEVT_FIRST + 13; -const wxEventType wxEVT_COMMAND_VLBOX_SELECTED = wxEVT_FIRST + 14; -const wxEventType wxEVT_COMMAND_COMBOBOX_SELECTED = wxEVT_FIRST + 15; -const wxEventType wxEVT_COMMAND_TOOL_RCLICKED = wxEVT_FIRST + 16; -const wxEventType wxEVT_COMMAND_TOOL_ENTER = wxEVT_FIRST + 17; -const wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED = wxEVT_FIRST + 18; - -/* Sockets send events, too */ -const wxEventType wxEVT_SOCKET = wxEVT_FIRST + 50; -const wxEventType wxEVT_TIMER = wxEVT_FIRST + 80; - -/* Mouse event types */ -const wxEventType wxEVT_LEFT_DOWN = wxEVT_FIRST + 100; -const wxEventType wxEVT_LEFT_UP = wxEVT_FIRST + 101; -const wxEventType wxEVT_MIDDLE_DOWN = wxEVT_FIRST + 102; -const wxEventType wxEVT_MIDDLE_UP = wxEVT_FIRST + 103; -const wxEventType wxEVT_RIGHT_DOWN = wxEVT_FIRST + 104; -const wxEventType wxEVT_RIGHT_UP = wxEVT_FIRST + 105; -const wxEventType wxEVT_MOTION = wxEVT_FIRST + 106; -const wxEventType wxEVT_ENTER_WINDOW = wxEVT_FIRST + 107; -const wxEventType wxEVT_LEAVE_WINDOW = wxEVT_FIRST + 108; -const wxEventType wxEVT_LEFT_DCLICK = wxEVT_FIRST + 109; -const wxEventType wxEVT_MIDDLE_DCLICK = wxEVT_FIRST + 110; -const wxEventType wxEVT_RIGHT_DCLICK = wxEVT_FIRST + 111; -const wxEventType wxEVT_SET_FOCUS = wxEVT_FIRST + 112; -const wxEventType wxEVT_KILL_FOCUS = wxEVT_FIRST + 113; - - /* Non-client mouse events */ -const wxEventType wxEVT_NC_LEFT_DOWN = wxEVT_FIRST + 200; -const wxEventType wxEVT_NC_LEFT_UP = wxEVT_FIRST + 201; -const wxEventType wxEVT_NC_MIDDLE_DOWN = wxEVT_FIRST + 202; -const wxEventType wxEVT_NC_MIDDLE_UP = wxEVT_FIRST + 203; -const wxEventType wxEVT_NC_RIGHT_DOWN = wxEVT_FIRST + 204; -const wxEventType wxEVT_NC_RIGHT_UP = wxEVT_FIRST + 205; -const wxEventType wxEVT_NC_MOTION = wxEVT_FIRST + 206; -const wxEventType wxEVT_NC_ENTER_WINDOW = wxEVT_FIRST + 207; -const wxEventType wxEVT_NC_LEAVE_WINDOW = wxEVT_FIRST + 208; -const wxEventType wxEVT_NC_LEFT_DCLICK = wxEVT_FIRST + 209; -const wxEventType wxEVT_NC_MIDDLE_DCLICK = wxEVT_FIRST + 210; -const wxEventType wxEVT_NC_RIGHT_DCLICK = wxEVT_FIRST + 211; - -/* Character input event type */ -const wxEventType wxEVT_CHAR = wxEVT_FIRST + 212; -const wxEventType wxEVT_CHAR_HOOK = wxEVT_FIRST + 213; -const wxEventType wxEVT_NAVIGATION_KEY = wxEVT_FIRST + 214; -const wxEventType wxEVT_KEY_DOWN = wxEVT_FIRST + 215; -const wxEventType wxEVT_KEY_UP = wxEVT_FIRST + 216; - - /* - * wxScrollbar and wxSlider event identifiers - */ -const wxEventType wxEVT_SCROLL_TOP = wxEVT_FIRST + 300; -const wxEventType wxEVT_SCROLL_BOTTOM = wxEVT_FIRST + 301; -const wxEventType wxEVT_SCROLL_LINEUP = wxEVT_FIRST + 302; -const wxEventType wxEVT_SCROLL_LINEDOWN = wxEVT_FIRST + 303; -const wxEventType wxEVT_SCROLL_PAGEUP = wxEVT_FIRST + 304; -const wxEventType wxEVT_SCROLL_PAGEDOWN = wxEVT_FIRST + 305; -const wxEventType wxEVT_SCROLL_THUMBTRACK = wxEVT_FIRST + 306; -const wxEventType wxEVT_SCROLL_THUMBRELEASE = wxEVT_FIRST + 307; - - /* - * Scroll events from wxWindow - */ -const wxEventType wxEVT_SCROLLWIN_TOP = wxEVT_FIRST + 320; -const wxEventType wxEVT_SCROLLWIN_BOTTOM = wxEVT_FIRST + 321; -const wxEventType wxEVT_SCROLLWIN_LINEUP = wxEVT_FIRST + 322; -const wxEventType wxEVT_SCROLLWIN_LINEDOWN = wxEVT_FIRST + 323; -const wxEventType wxEVT_SCROLLWIN_PAGEUP = wxEVT_FIRST + 324; -const wxEventType wxEVT_SCROLLWIN_PAGEDOWN = wxEVT_FIRST + 325; -const wxEventType wxEVT_SCROLLWIN_THUMBTRACK = wxEVT_FIRST + 326; -const wxEventType wxEVT_SCROLLWIN_THUMBRELEASE = wxEVT_FIRST + 327; - - /* - * System events - */ -const wxEventType wxEVT_SIZE = wxEVT_FIRST + 400; -const wxEventType wxEVT_MOVE = wxEVT_FIRST + 401; -const wxEventType wxEVT_CLOSE_WINDOW = wxEVT_FIRST + 402; -const wxEventType wxEVT_END_SESSION = wxEVT_FIRST + 403; -const wxEventType wxEVT_QUERY_END_SESSION = wxEVT_FIRST + 404; -const wxEventType wxEVT_ACTIVATE_APP = wxEVT_FIRST + 405; -const wxEventType wxEVT_POWER = wxEVT_FIRST + 406; -const wxEventType wxEVT_ACTIVATE = wxEVT_FIRST + 409; -const wxEventType wxEVT_CREATE = wxEVT_FIRST + 410; -const wxEventType wxEVT_DESTROY = wxEVT_FIRST + 411; -const wxEventType wxEVT_SHOW = wxEVT_FIRST + 412; -const wxEventType wxEVT_ICONIZE = wxEVT_FIRST + 413; -const wxEventType wxEVT_MAXIMIZE = wxEVT_FIRST + 414; -const wxEventType wxEVT_MOUSE_CAPTURE_CHANGED = wxEVT_FIRST + 415; -const wxEventType wxEVT_PAINT = wxEVT_FIRST + 416; -const wxEventType wxEVT_ERASE_BACKGROUND = wxEVT_FIRST + 417; -const wxEventType wxEVT_NC_PAINT = wxEVT_FIRST + 418; -const wxEventType wxEVT_PAINT_ICON = wxEVT_FIRST + 419; -const wxEventType wxEVT_MENU_CHAR = wxEVT_FIRST + 420; -const wxEventType wxEVT_MENU_INIT = wxEVT_FIRST + 421; -const wxEventType wxEVT_MENU_HIGHLIGHT = wxEVT_FIRST + 422; -const wxEventType wxEVT_POPUP_MENU_INIT = wxEVT_FIRST + 423; -const wxEventType wxEVT_CONTEXT_MENU = wxEVT_FIRST + 424; -const wxEventType wxEVT_SYS_COLOUR_CHANGED = wxEVT_FIRST + 425; -const wxEventType wxEVT_SETTING_CHANGED = wxEVT_FIRST + 426; -const wxEventType wxEVT_QUERY_NEW_PALETTE = wxEVT_FIRST + 427; -const wxEventType wxEVT_PALETTE_CHANGED = wxEVT_FIRST + 428; -const wxEventType wxEVT_JOY_BUTTON_DOWN = wxEVT_FIRST + 429; -const wxEventType wxEVT_JOY_BUTTON_UP = wxEVT_FIRST + 430; -const wxEventType wxEVT_JOY_MOVE = wxEVT_FIRST + 431; -const wxEventType wxEVT_JOY_ZMOVE = wxEVT_FIRST + 432; -const wxEventType wxEVT_DROP_FILES = wxEVT_FIRST + 433; -const wxEventType wxEVT_DRAW_ITEM = wxEVT_FIRST + 434; -const wxEventType wxEVT_MEASURE_ITEM = wxEVT_FIRST + 435; -const wxEventType wxEVT_COMPARE_ITEM = wxEVT_FIRST + 436; -const wxEventType wxEVT_INIT_DIALOG = wxEVT_FIRST + 437; -const wxEventType wxEVT_IDLE = wxEVT_FIRST + 438; -const wxEventType wxEVT_UPDATE_UI = wxEVT_FIRST + 439; - - /* System misc. */ -const wxEventType wxEVT_END_PROCESS = wxEVT_FIRST + 440; - - /* Dial up events */ -const wxEventType wxEVT_DIALUP_CONNECTED = wxEVT_FIRST + 450; -const wxEventType wxEVT_DIALUP_DISCONNECTED = wxEVT_FIRST + 451; - - /* Generic command events */ - /* Note: a click is a higher-level event than button down/up */ -const wxEventType wxEVT_COMMAND_LEFT_CLICK = wxEVT_FIRST + 500; -const wxEventType wxEVT_COMMAND_LEFT_DCLICK = wxEVT_FIRST + 501; -const wxEventType wxEVT_COMMAND_RIGHT_CLICK = wxEVT_FIRST + 502; -const wxEventType wxEVT_COMMAND_RIGHT_DCLICK = wxEVT_FIRST + 503; -const wxEventType wxEVT_COMMAND_SET_FOCUS = wxEVT_FIRST + 504; -const wxEventType wxEVT_COMMAND_KILL_FOCUS = wxEVT_FIRST + 505; -const wxEventType wxEVT_COMMAND_ENTER = wxEVT_FIRST + 506; - - /* Tree control event types */ -const wxEventType wxEVT_COMMAND_TREE_BEGIN_DRAG = wxEVT_FIRST + 600; -const wxEventType wxEVT_COMMAND_TREE_BEGIN_RDRAG = wxEVT_FIRST + 601; -const wxEventType wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT = wxEVT_FIRST + 602; -const wxEventType wxEVT_COMMAND_TREE_END_LABEL_EDIT = wxEVT_FIRST + 603; -const wxEventType wxEVT_COMMAND_TREE_DELETE_ITEM = wxEVT_FIRST + 604; -const wxEventType wxEVT_COMMAND_TREE_GET_INFO = wxEVT_FIRST + 605; -const wxEventType wxEVT_COMMAND_TREE_SET_INFO = wxEVT_FIRST + 606; -const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDED = wxEVT_FIRST + 607; -const wxEventType wxEVT_COMMAND_TREE_ITEM_EXPANDING = wxEVT_FIRST + 608; -const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSED = wxEVT_FIRST + 609; -const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxEVT_FIRST + 610; -const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611; -const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612; -const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613; -const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxEVT_FIRST + 614; -const wxEventType wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxEVT_FIRST + 615; -const wxEventType wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 616; - - /* List control event types */ -const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700; -const wxEventType wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxEVT_FIRST + 701; -const wxEventType wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxEVT_FIRST + 702; -const wxEventType wxEVT_COMMAND_LIST_END_LABEL_EDIT = wxEVT_FIRST + 703; -const wxEventType wxEVT_COMMAND_LIST_DELETE_ITEM = wxEVT_FIRST + 704; -const wxEventType wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS = wxEVT_FIRST + 705; -const wxEventType wxEVT_COMMAND_LIST_GET_INFO = wxEVT_FIRST + 706; -const wxEventType wxEVT_COMMAND_LIST_SET_INFO = wxEVT_FIRST + 707; -const wxEventType wxEVT_COMMAND_LIST_ITEM_SELECTED = wxEVT_FIRST + 708; -const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxEVT_FIRST + 709; -const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN = wxEVT_FIRST + 710; -const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM = wxEVT_FIRST + 711; -const wxEventType wxEVT_COMMAND_LIST_COL_CLICK = wxEVT_FIRST + 712; -const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713; -const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714; -const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxEVT_FIRST + 715; - - /* Tab and notebook control event types */ -const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800; -const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGING = wxEVT_FIRST + 801; -const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED = wxEVT_FIRST + 802; -const wxEventType wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING = wxEVT_FIRST + 803; - -/* Splitter events */ -const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGED = wxEVT_FIRST + 850; -const wxEventType wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING = wxEVT_FIRST + 851; -const wxEventType wxEVT_COMMAND_SPLITTER_DOUBLECLICKED = wxEVT_FIRST + 852; -const wxEventType wxEVT_COMMAND_SPLITTER_UNSPLIT = wxEVT_FIRST + 853; - -/* Wizard events */ -const wxEventType wxEVT_WIZARD_PAGE_CHANGED = wxEVT_FIRST + 900; -const wxEventType wxEVT_WIZARD_PAGE_CHANGING = wxEVT_FIRST + 901; -const wxEventType wxEVT_WIZARD_CANCEL = wxEVT_FIRST + 902; - -/* Calendar events */ -const wxEventType wxEVT_CALENDAR_SEL_CHANGED = wxEVT_FIRST + 950; -const wxEventType wxEVT_CALENDAR_DAY_CHANGED = wxEVT_FIRST + 951; -const wxEventType wxEVT_CALENDAR_MONTH_CHANGED = wxEVT_FIRST + 952; -const wxEventType wxEVT_CALENDAR_YEAR_CHANGED = wxEVT_FIRST + 953; -const wxEventType wxEVT_CALENDAR_DOUBLECLICKED = wxEVT_FIRST + 954; -const wxEventType wxEVT_CALENDAR_WEEKDAY_CLICKED = wxEVT_FIRST + 955; - -const wxEventType wxEVT_USER_FIRST = wxEVT_FIRST + 2000; -#endif - // ---------------------------------------------------------------------------- // wxWin macros // ---------------------------------------------------------------------------- - IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) - IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) - IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent) +IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxIdleEvent, wxEvent) - #if wxUSE_GUI - IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent) - IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent, wxEvent) - IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent) - #endif // wxUSE_GUI +#if wxUSE_GUI + IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxScrollWinEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxSizeEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxPaintEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxEraseEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMoveEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxFocusEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxCloseEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxShowEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMaximizeEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxIconizeEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxMenuEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxJoystickEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxDropFilesEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxActivateEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxInitDialogEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxSysColourChangedEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxUpdateUIEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxNavigationKeyEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxPaletteChangedEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxQueryNewPaletteEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxWindowCreateEvent, wxEvent) + IMPLEMENT_DYNAMIC_CLASS(wxWindowDestroyEvent, wxEvent) +#endif // wxUSE_GUI - const wxEventTable *wxEvtHandler::GetEventTable() const - { return &wxEvtHandler::sm_eventTable; } +const wxEventTable *wxEvtHandler::GetEventTable() const + { return &wxEvtHandler::sm_eventTable; } - const wxEventTable wxEvtHandler::sm_eventTable = - { (const wxEventTable *)NULL, &wxEvtHandler::sm_eventTableEntries[0] }; +const wxEventTable wxEvtHandler::sm_eventTable = + { (const wxEventTable *)NULL, &wxEvtHandler::sm_eventTableEntries[0] }; - const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = - { { 0, 0, 0, (wxObjectEventFunction) NULL, (wxObject*) NULL } }; +const wxEventTableEntry wxEvtHandler::sm_eventTableEntries[] = + { { 0, 0, 0, (wxObjectEventFunction) NULL, (wxObject*) NULL } }; // ---------------------------------------------------------------------------- @@ -421,6 +205,19 @@ wxScrollEvent::wxScrollEvent(wxEventType commandType, { m_extraLong = orient; m_commandInt = pos; +<<<<<<< event.cpp + m_isScrolling = TRUE; +} + +void wxScrollEvent::CopyObject(wxObject& obj_d) const +{ + wxScrollEvent *obj = (wxScrollEvent*)&obj_d; + + wxCommandEvent::CopyObject(obj_d); + + obj->m_isScrolling = m_isScrolling; +======= +>>>>>>> 1.69 } /* diff --git a/src/generic/logg.cpp b/src/generic/logg.cpp index 9ca1c086c1..16f6148ca4 100644 --- a/src/generic/logg.cpp +++ b/src/generic/logg.cpp @@ -210,48 +210,62 @@ void wxLogGui::Flush() style = wxICON_INFORMATION; } -#if wxUSE_LOG_DIALOG - wxLogDialog dlg(wxTheApp->GetTopWindow(), - m_aMessages, m_aSeverity, m_aTimes, - title, style); + // this is the best we can do here + wxWindow *parent = wxTheApp->GetTopWindow(); - // clear the message list before showing the dialog because while it's - // shown some new messages may appear - Clear(); + size_t nMsgCount = m_aMessages.Count(); - (void)dlg.ShowModal(); + wxString str; + if ( nMsgCount == 1 ) + { + str = m_aMessages[0]; + } + else // more than one message + { +#if wxUSE_LOG_DIALOG + wxLogDialog dlg(parent, + m_aMessages, m_aSeverity, m_aTimes, + title, style); + // clear the message list before showing the dialog because while it's + // shown some new messages may appear + Clear(); + + (void)dlg.ShowModal(); #else // !wxUSE_LOG_DIALOG - // concatenate all strings (but not too many to not overfill the msg box) - wxString str; - size_t nLines = 0, - nMsgCount = m_aMessages.Count(); + // concatenate all strings (but not too many to not overfill the msg box) + size_t nLines = 0; - // start from the most recent message - for ( size_t n = nMsgCount; n > 0; n-- ) { - // for Windows strings longer than this value are wrapped (NT 4.0) - const size_t nMsgLineWidth = 156; + // start from the most recent message + for ( size_t n = nMsgCount; n > 0; n-- ) { + // for Windows strings longer than this value are wrapped (NT 4.0) + const size_t nMsgLineWidth = 156; - nLines += (m_aMessages[n - 1].Len() + nMsgLineWidth - 1) / nMsgLineWidth; + nLines += (m_aMessages[n - 1].Len() + nMsgLineWidth - 1) / nMsgLineWidth; - if ( nLines > 25 ) // don't put too many lines in message box - break; + if ( nLines > 25 ) // don't put too many lines in message box + break; - str << m_aMessages[n - 1] << wxT("\n"); + str << m_aMessages[n - 1] << wxT("\n"); + } +#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG } - wxMessageBox(str, title, wxOK | style); + // this catches both cases of 1 message with wxUSE_LOG_DIALOG and any + // situation without it + if ( !!str ) + { + wxMessageBox(str, title, wxOK | style, parent); - // no undisplayed messages whatsoever - Clear(); -#endif // wxUSE_LOG_DIALOG/!wxUSE_LOG_DIALOG + // no undisplayed messages whatsoever + Clear(); + } // do it here again m_bHasMessages = FALSE; } -// the default behaviour is to discard all informational messages if there -// are any errors/warnings. +// log all kinds of messages void wxLogGui::DoLog(wxLogLevel level, const wxChar *szString, time_t t) { switch ( level ) { @@ -696,12 +710,15 @@ wxLogDialog::wxLogDialog(wxWindow *parent, btnOk->SetFocus(); + // this can't happen any more as we don't use this dialog in this case +#if 0 if ( count == 1 ) { // no details... it's easier to disable a button than to change the // dialog layout depending on whether we have details or not m_btnDetails->Disable(); } +#endif // 0 Centre(); } diff --git a/src/msw/dragimag.cpp b/src/msw/dragimag.cpp index a2793f86bc..1ce8b4e548 100644 --- a/src/msw/dragimag.cpp +++ b/src/msw/dragimag.cpp @@ -6,9 +6,17 @@ // Created: 08/04/99 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + #ifdef __GNUG__ #pragma implementation "dragimag.h" #endif @@ -39,12 +47,26 @@ #include "wx/msw/dragimag.h" #include "wx/msw/private.h" -#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) +#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) #include #endif +// ---------------------------------------------------------------------------- +// macros +// ---------------------------------------------------------------------------- + IMPLEMENT_DYNAMIC_CLASS(wxDragImage, wxObject) +#define GetHimageList() ((HIMAGELIST) m_hImageList) + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// wxDragImage ctors/dtor +// ---------------------------------------------------------------------------- + wxDragImage::wxDragImage() { m_hImageList = 0; @@ -52,9 +74,8 @@ wxDragImage::wxDragImage() wxDragImage::~wxDragImage() { - if ( m_hImageList ) - ImageList_Destroy((HIMAGELIST) m_hImageList); - m_hImageList = 0; + if ( m_hImageList ) + ImageList_Destroy(GetHimageList()); } @@ -68,24 +89,24 @@ wxDragImage::~wxDragImage() // Create a drag image from a bitmap and optional cursor bool wxDragImage::Create(const wxBitmap& image, const wxCursor& cursor, const wxPoint& hotspot) { - if ( m_hImageList ) - ImageList_Destroy((HIMAGELIST) m_hImageList); - m_hImageList = 0; + if ( m_hImageList ) + ImageList_Destroy(GetHimageList()); + m_hImageList = 0; - UINT flags = 0; + UINT flags = 0; bool mask = TRUE; // ? - if ( mask ) - flags |= ILC_MASK; + if ( mask ) + flags |= ILC_MASK; - m_hImageList = (WXHIMAGELIST) ImageList_Create(image.GetWidth(), image.GetHeight(), flags, 1, 1); + m_hImageList = (WXHIMAGELIST) ImageList_Create(image.GetWidth(), image.GetHeight(), flags, 1, 1); - HBITMAP hBitmap1 = (HBITMAP) image.GetHBITMAP(); - HBITMAP hBitmap2 = 0; - if ( image.GetMask() ) - hBitmap2 = (HBITMAP) image.GetMask()->GetMaskBitmap(); + HBITMAP hBitmap1 = (HBITMAP) image.GetHBITMAP(); + HBITMAP hBitmap2 = 0; + if ( image.GetMask() ) + hBitmap2 = (HBITMAP) image.GetMask()->GetMaskBitmap(); - int index = ImageList_Add((HIMAGELIST) m_hImageList, hBitmap1, hBitmap2); - if ( index == -1 ) + int index = ImageList_Add(GetHimageList(), hBitmap1, hBitmap2); + if ( index == -1 ) { wxLogError(_("Couldn't add an image to the image list.")); } @@ -95,25 +116,25 @@ bool wxDragImage::Create(const wxBitmap& image, const wxCursor& cursor, const wx return (index != -1) ; } - + // Create a drag image from an icon and optional cursor bool wxDragImage::Create(const wxIcon& image, const wxCursor& cursor, const wxPoint& hotspot) { - if ( m_hImageList ) - ImageList_Destroy((HIMAGELIST) m_hImageList); - m_hImageList = 0; + if ( m_hImageList ) + ImageList_Destroy(GetHimageList()); + m_hImageList = 0; - UINT flags = 0; + UINT flags = 0; bool mask = TRUE; // ? - if ( mask ) - flags |= ILC_MASK; + if ( mask ) + flags |= ILC_MASK; - m_hImageList = (WXHIMAGELIST) ImageList_Create(image.GetWidth(), image.GetHeight(), flags, 1, 1); + m_hImageList = (WXHIMAGELIST) ImageList_Create(image.GetWidth(), image.GetHeight(), flags, 1, 1); - HICON hIcon = (HICON) image.GetHICON(); + HICON hIcon = (HICON) image.GetHICON(); - int index = ImageList_AddIcon((HIMAGELIST) m_hImageList, hIcon); - if ( index == -1 ) + int index = ImageList_AddIcon(GetHimageList(), hIcon); + if ( index == -1 ) { wxLogError(_("Couldn't add an image to the image list.")); } @@ -123,7 +144,7 @@ bool wxDragImage::Create(const wxIcon& image, const wxCursor& cursor, const wxPo return (index != -1) ; } - + // Create a drag image from a string and optional cursor bool wxDragImage::Create(const wxString& str, const wxCursor& cursor, const wxPoint& hotspot) { @@ -151,8 +172,8 @@ bool wxDragImage::Create(const wxString& str, const wxCursor& cursor, const wxPo // Create a drag image for the given tree control item bool wxDragImage::Create(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) { - if ( m_hImageList ) - ImageList_Destroy((HIMAGELIST) m_hImageList); + if ( m_hImageList ) + ImageList_Destroy(GetHimageList()); m_hImageList = (WXHIMAGELIST) TreeView_CreateDragImage((HWND) treeCtrl.GetHWND(), (HTREEITEM) (WXHTREEITEM) id); return TRUE; } @@ -160,8 +181,8 @@ bool wxDragImage::Create(const wxTreeCtrl& treeCtrl, wxTreeItemId& id) // Create a drag image for the given list control item bool wxDragImage::Create(const wxListCtrl& listCtrl, long id) { - if ( m_hImageList ) - ImageList_Destroy((HIMAGELIST) m_hImageList); + if ( m_hImageList ) + ImageList_Destroy(GetHimageList()); POINT pt; pt.x = 0; pt.y = 0; m_hImageList = (WXHIMAGELIST) ListView_CreateDragImage((HWND) listCtrl.GetHWND(), id, & pt); @@ -169,35 +190,38 @@ bool wxDragImage::Create(const wxListCtrl& listCtrl, long id) } // Begin drag -bool wxDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* WXUNUSED(window)) +bool wxDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* window) { wxASSERT_MSG( (m_hImageList != 0), wxT("Image list must not be null in BeginDrag.")); - bool ret = (ImageList_BeginDrag((HIMAGELIST) m_hImageList, 0, hotspot.x, hotspot.y) != 0); - - wxASSERT_MSG( (ret), wxT("BeginDrag failed.")); + bool ret = (ImageList_BeginDrag(GetHimageList(), 0, hotspot.x, hotspot.y) != 0); if (!ret) + { + wxFAIL_MSG( _T("BeginDrag failed.") ); + return FALSE; + } if (m_cursor.Ok()) { // First add the cursor to the image list - int cursorIndex = ImageList_AddIcon((HIMAGELIST) m_hImageList, (HICON) m_cursor.GetHCURSOR()); + int cursorIndex = ImageList_AddIcon(GetHimageList(), (HICON) m_cursor.GetHCURSOR()); wxASSERT_MSG( (cursorIndex != -1), wxT("ImageList_AddIcon failed in BeginDrag.")); if (cursorIndex != -1) { - ImageList_SetDragCursorImage((HIMAGELIST) m_hImageList, cursorIndex, m_hotspot.x, m_hotspot.y); + ImageList_SetDragCursorImage(GetHimageList(), cursorIndex, m_hotspot.x, m_hotspot.y); } } ::ShowCursor(FALSE); + ::SetCapture(GetHwndOf(window)); return TRUE; } - + // End drag bool wxDragImage::EndDrag(wxWindow* WXUNUSED(window)) { @@ -205,11 +229,16 @@ bool wxDragImage::EndDrag(wxWindow* WXUNUSED(window)) ImageList_EndDrag(); + if ( !::ReleaseCapture() ) + { + wxLogLastError("ReleaseCapture"); + } + ::ShowCursor(TRUE); return TRUE; } - + // Move the image: call from OnMouseMove. Pt is in window client coordinates if window // is non-NULL, or in screen coordinates if NULL. bool wxDragImage::Move(const wxPoint& pt, wxWindow* window) diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 16ae2a1261..55b6946d0d 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -2,7 +2,7 @@ // Name: msw/registry.cpp // Purpose: implementation of registry classes and functions // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 03.04.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -65,8 +65,8 @@ static struct const wxChar *szName; const wxChar *szShortName; } -aStdKeys[] = -{ +aStdKeys[] = +{ { HKEY_CLASSES_ROOT, wxT("HKEY_CLASSES_ROOT"), wxT("HKCR") }, #ifdef __WIN32__ { HKEY_CURRENT_USER, wxT("HKEY_CURRENT_USER"), wxT("HKCU") }, @@ -110,7 +110,7 @@ static inline void RemoveTrailingSeparator(wxString& str); static bool KeyExists(WXHKEY hRootKey, const wxChar *szKey); // combines value and key name (uses static buffer!) -static const wxChar *GetFullName(const wxRegKey *pKey, +static const wxChar *GetFullName(const wxRegKey *pKey, const wxChar *szValue = NULL); // ============================================================================ @@ -124,7 +124,7 @@ static const wxChar *GetFullName(const wxRegKey *pKey, const size_t wxRegKey::nStdKeys = WXSIZEOF(aStdKeys); // @@ should take a `StdKey key', but as it's often going to be used in loops -// it would require casts in user code. +// it would require casts in user code. const wxChar *wxRegKey::GetStdKeyName(size_t key) { // return empty string if key is invalid @@ -148,7 +148,7 @@ wxRegKey::StdKey wxRegKey::ExtractKeyName(wxString& strKey) HKEY hRootKey = 0; size_t ui; for ( ui = 0; ui < nStdKeys; ui++ ) { - if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 || + if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 || strRoot.CmpNoCase(aStdKeys[ui].szShortName) == 0 ) { hRootKey = aStdKeys[ui].hkey; break; @@ -175,7 +175,7 @@ wxRegKey::StdKey wxRegKey::GetStdKeyFromHkey(WXHKEY hkey) if ( (int) aStdKeys[ui].hkey == (int) hkey ) return (StdKey)ui; } - + wxFAIL_MSG(wxT("non root hkey passed to wxRegKey::GetStdKeyFromHkey.")); return HKCR; @@ -213,7 +213,7 @@ wxRegKey::wxRegKey(const wxRegKey& keyParent, const wxString& strKey) : m_strKey(keyParent.m_strKey) { // combine our name with parent's to get the full name - if ( !m_strKey.IsEmpty() && + if ( !m_strKey.IsEmpty() && (strKey.IsEmpty() || strKey[0] != REG_SEPARATOR) ) { m_strKey += REG_SEPARATOR; } @@ -294,7 +294,7 @@ bool wxRegKey::Exists() const wxString wxRegKey::GetName(bool bShortPrefix) const { StdKey key = GetStdKeyFromHkey((StdKey) m_hRootKey); - wxString str = bShortPrefix ? aStdKeys[key].szShortName + wxString str = bShortPrefix ? aStdKeys[key].szShortName : aStdKeys[key].szName; if ( !m_strKey.IsEmpty() ) str << "\\" << m_strKey; @@ -302,37 +302,44 @@ wxString wxRegKey::GetName(bool bShortPrefix) const return str; } -#if defined( __GNUWIN32_OLD__ ) -bool wxRegKey::GetKeyInfo(size_t* pnSubKeys, - size_t* pnMaxKeyLen, - size_t* pnValues, - size_t* pnMaxValueLen) const -#else -bool wxRegKey::GetKeyInfo(ulong *pnSubKeys, - ulong *pnMaxKeyLen, - ulong *pnValues, - ulong *pnMaxValueLen) const -#endif +bool wxRegKey::GetKeyInfo(size_t *pnSubKeys, + size_t *pnMaxKeyLen, + size_t *pnValues, + size_t *pnMaxValueLen) const { #if defined(__WIN32__) && !defined(__TWIN32__) + + // old gcc headers incorrectly prototype RegQueryInfoKey() +#ifdef __GNUWIN32_OLD__ + #define REG_PARAM (size_t *) +#else + #define REG_PARAM (LPDWORD) +#endif + m_dwLastError = ::RegQueryInfoKey ( (HKEY) m_hKey, NULL, // class name NULL, // (ptr to) size of class name buffer RESERVED, + REG_PARAM pnSubKeys, // [out] number of subkeys + REG_PARAM pnMaxKeyLen, // [out] max length of a subkey name NULL, // longest subkey class name + REG_PARAM pnValues, // [out] number of values + REG_PARAM pnMaxValueLen, // [out] max length of a value name NULL, // longest value data NULL, // security descriptor NULL // time of last modification ); +#undef REG_PARAM + if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't get info about registry key '%s'"), + wxLogSysError(m_dwLastError, _("Can't get info about registry key '%s'"), GetName().c_str()); return FALSE; } @@ -358,7 +365,7 @@ bool wxRegKey::Open() HKEY tmpKey; m_dwLastError = RegOpenKey((HKEY) m_hRootKey, m_strKey, &tmpKey); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't open registry key '%s'"), + wxLogSysError(m_dwLastError, _("Can't open registry key '%s'"), GetName().c_str()); return FALSE; } @@ -383,7 +390,7 @@ bool wxRegKey::Create(bool bOkIfExists) HKEY tmpKey; m_dwLastError = RegCreateKey((HKEY) m_hRootKey, m_strKey, &tmpKey); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't create registry key '%s'"), + wxLogSysError(m_dwLastError, _("Can't create registry key '%s'"), GetName().c_str()); return FALSE; } @@ -400,7 +407,7 @@ bool wxRegKey::Close() if ( IsOpened() ) { m_dwLastError = RegCloseKey((HKEY) m_hKey); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't close registry key '%s'"), + wxLogSysError(m_dwLastError, _("Can't close registry key '%s'"), GetName().c_str()); m_hKey = 0; @@ -414,6 +421,126 @@ bool wxRegKey::Close() return TRUE; } +bool wxRegKey::RenameValue(const wxChar *szValueOld, const wxChar *szValueNew) +{ + bool ok = TRUE; + if ( HasValue(szValueNew) ) { + wxLogError(_("Registry value '%s' already exists."), szValueNew); + + ok = FALSE; + } + + if ( !ok || !CopyValue(szValueOld, *this, szValueNew) ) { + wxLogError(_("Failed to rename registry value '%s' to '%s'."), + szValueOld, szValueNew); + + return FALSE; + } + + return TRUE; +} + +bool wxRegKey::CopyValue(const wxChar *szValue, + wxRegKey& keyDst, + const wxChar *szValueNew) +{ + switch ( GetValueType(szValue) ) { + case Type_String: + { + wxString strVal; + return QueryValue(szValue, strVal) && + keyDst.SetValue(szValueNew, strVal); + } + + case Type_Dword: + /* case Type_Dword_little_endian: == Type_Dword */ + { + long dwVal; + return QueryValue(szValue, &dwVal) && + keyDst.SetValue(szValueNew, dwVal); + } + + // these types are unsupported because I am not sure about how + // exactly they should be copied and because they shouldn't + // occur among the application keys (supposedly created with + // this class) +#ifdef __WIN32__ + case Type_None: + case Type_Expand_String: + case Type_Binary: + case Type_Dword_big_endian: + case Type_Link: + case Type_Multi_String: + case Type_Resource_list: + case Type_Full_resource_descriptor: + case Type_Resource_requirements_list: +#endif // Win32 + default: + wxLogError(_("Can't copy values of unsupported type %d."), + GetValueType(szValue)); + return FALSE; + } +} + +bool wxRegKey::Copy(const wxString& strNewName) +{ + // create the new key first + wxRegKey keyDst(strNewName); + bool ok = keyDst.Create(FALSE /* fail if alredy exists */); + if ( ok ) { + ok = Copy(keyDst); + + // we created the dest key but copying to it failed - delete it + if ( !ok ) { + (void)keyDst.DeleteSelf(); + } + } + + return ok; +} + +bool wxRegKey::Copy(wxRegKey& keyDst) +{ + bool ok = TRUE; + + // copy all sub keys to the new location + wxString strKey; + long lIndex; + bool bCont = GetFirstKey(strKey, lIndex); + while ( ok && bCont ) { + wxRegKey key(*this, strKey); + wxString keyName; + keyName << GetFullName(&keyDst) << REG_SEPARATOR << strKey; + ok = key.Copy(keyName); + + if ( ok ) + bCont = GetNextKey(strKey, lIndex); + } + + // copy all values + wxString strVal; + bCont = GetFirstValue(strVal, lIndex); + while ( ok && bCont ) { + ok = CopyValue(strVal, keyDst); + + if ( !ok ) { + wxLogSysError(m_dwLastError, + _("Failed to copy registry value '%s'"), + strVal.c_str()); + } + else { + bCont = GetNextValue(strVal, lIndex); + } + } + + if ( !ok ) { + wxLogError(_("Failed to copy the contents of registry key '%s' to " + "'%s'."), GetFullName(this), GetFullName(&keyDst)); + } + + return ok; +} + // ---------------------------------------------------------------------------- // delete keys/values // ---------------------------------------------------------------------------- @@ -464,7 +591,7 @@ bool wxRegKey::DeleteSelf() m_dwLastError = RegDeleteKey((HKEY) m_hRootKey, m_strKey); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't delete key '%s'"), + wxLogSysError(m_dwLastError, _("Can't delete key '%s'"), GetName().c_str()); return FALSE; } @@ -489,7 +616,7 @@ bool wxRegKey::DeleteValue(const wxChar *szValue) #if defined(__WIN32__) && !defined(__TWIN32__) m_dwLastError = RegDeleteValue((HKEY) m_hKey, WXSTRINGCAST szValue); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't delete value '%s' from key '%s'"), + wxLogSysError(m_dwLastError, _("Can't delete value '%s' from key '%s'"), szValue, GetName().c_str()); return FALSE; } @@ -500,7 +627,7 @@ bool wxRegKey::DeleteValue(const wxChar *szValue) // just set the (default and unique) value of the key to "" m_dwLastError = RegSetValue((HKEY) m_hKey, NULL, REG_SZ, "", RESERVED); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't delete value of key '%s'"), + wxLogSysError(m_dwLastError, _("Can't delete value of key '%s'"), GetName().c_str()); return FALSE; } @@ -518,7 +645,7 @@ bool wxRegKey::HasValue(const wxChar *szValue) const { // this function should be silent, so suppress possible messages from Open() wxLogNull nolog; - + #ifdef __WIN32__ if ( CONST_CAST Open() ) { return RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, @@ -537,7 +664,7 @@ bool wxRegKey::HasValues() const { // suppress possible messages from GetFirstValue() wxLogNull nolog; - + // just call GetFirstValue with dummy parameters wxString str; long l; @@ -549,7 +676,7 @@ bool wxRegKey::HasSubkeys() const { // suppress possible messages from GetFirstKey() wxLogNull nolog; - + // just call GetFirstKey with dummy parameters wxString str; long l; @@ -561,7 +688,7 @@ bool wxRegKey::HasSubKey(const wxChar *szKey) const { // this function should be silent, so suppress possible messages from Open() wxLogNull nolog; - + if ( CONST_CAST Open() ) return KeyExists(m_hKey, szKey); else @@ -578,7 +705,7 @@ wxRegKey::ValueType wxRegKey::GetValueType(const wxChar *szValue) const m_dwLastError = RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, &dwType, NULL, NULL); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't read value of key '%s'"), + wxLogSysError(m_dwLastError, _("Can't read value of key '%s'"), GetName().c_str()); return Type_None; } @@ -603,7 +730,7 @@ bool wxRegKey::SetValue(const wxChar *szValue, long lValue) return TRUE; } - wxLogSysError(m_dwLastError, _("can't set value of '%s'"), + wxLogSysError(m_dwLastError, _("Can't set value of '%s'"), GetFullName(this, szValue)); return FALSE; #endif @@ -617,13 +744,13 @@ bool wxRegKey::QueryValue(const wxChar *szValue, long *plValue) const m_dwLastError = RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, &dwType, pBuf, &dwSize); if ( m_dwLastError != ERROR_SUCCESS ) { - wxLogSysError(m_dwLastError, _("can't read value of key '%s'"), + wxLogSysError(m_dwLastError, _("Can't read value of key '%s'"), GetName().c_str()); return FALSE; } else { // check that we read the value of right type - wxASSERT_MSG( dwType == REG_DWORD, + wxASSERT_MSG( IsNumericValue(szValue), wxT("Type mismatch in wxRegKey::QueryValue().") ); return TRUE; @@ -644,13 +771,25 @@ bool wxRegKey::QueryValue(const wxChar *szValue, wxString& strValue) const m_dwLastError = RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, &dwType, NULL, &dwSize); if ( m_dwLastError == ERROR_SUCCESS ) { - RegString pBuf = (RegString)strValue.GetWriteBuf(dwSize); - m_dwLastError = RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, - &dwType, pBuf, &dwSize); - strValue.UngetWriteBuf(); + if ( !dwSize ) { + // must treat this case specially as GetWriteBuf() doesn't like + // being called with 0 size + strValue.Empty(); + } + else { + RegString pBuf = (RegString)strValue.GetWriteBuf(dwSize); + m_dwLastError = RegQueryValueEx((HKEY) m_hKey, + WXSTRINGCAST szValue, + RESERVED, + &dwType, + pBuf, + &dwSize); + strValue.UngetWriteBuf(); + } + if ( m_dwLastError == ERROR_SUCCESS ) { // check that it was the right type - wxASSERT_MSG( dwType == REG_SZ, + wxASSERT_MSG( !IsNumericValue(szValue), wxT("Type mismatch in wxRegKey::QueryValue().") ); return TRUE; @@ -667,7 +806,7 @@ bool wxRegKey::QueryValue(const wxChar *szValue, wxString& strValue) const #endif //WIN16/32 } - wxLogSysError(m_dwLastError, _("can't read value of '%s'"), + wxLogSysError(m_dwLastError, _("Can't read value of '%s'"), GetFullName(this, szValue)); return FALSE; } @@ -677,7 +816,7 @@ bool wxRegKey::SetValue(const wxChar *szValue, const wxString& strValue) if ( CONST_CAST Open() ) { #if defined( __WIN32__) && !defined(__TWIN32__) m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, (DWORD) RESERVED, REG_SZ, - (RegString)strValue.c_str(), + (RegString)strValue.c_str(), strValue.Len() + 1); if ( m_dwLastError == ERROR_SUCCESS ) return TRUE; @@ -691,7 +830,7 @@ bool wxRegKey::SetValue(const wxChar *szValue, const wxString& strValue) #endif //WIN16/32 } - wxLogSysError(m_dwLastError, _("can't set value of '%s'"), + wxLogSysError(m_dwLastError, _("Can't set value of '%s'"), GetFullName(this, szValue)); return FALSE; } @@ -732,8 +871,8 @@ bool wxRegKey::GetNextValue(wxString& strValueName, long& lIndex) const m_dwLastError = RegEnumValue((HKEY) m_hKey, lIndex++, szValueName, &dwValueLen, - RESERVED, - NULL, // [out] type + RESERVED, + NULL, // [out] type NULL, // [out] buffer for value NULL); // [i/o] it's length @@ -743,7 +882,7 @@ bool wxRegKey::GetNextValue(wxString& strValueName, long& lIndex) const lIndex = -1; } else { - wxLogSysError(m_dwLastError, _("can't enumerate values of key '%s'"), + wxLogSysError(m_dwLastError, _("Can't enumerate values of key '%s'"), GetName().c_str()); } @@ -788,7 +927,7 @@ bool wxRegKey::GetNextKey(wxString& strKeyName, long& lIndex) const lIndex = -1; } else { - wxLogSysError(m_dwLastError, _("can't enumerate subkeys of key '%s'"), + wxLogSysError(m_dwLastError, _("Can't enumerate subkeys of key '%s'"), GetName().c_str()); } @@ -801,11 +940,11 @@ bool wxRegKey::GetNextKey(wxString& strKeyName, long& lIndex) const // returns TRUE if the value contains a number (else it's some string) bool wxRegKey::IsNumericValue(const wxChar *szValue) const - { + { ValueType type = GetValueType(szValue); switch ( type ) { case Type_Dword: - case Type_Dword_little_endian: + /* case Type_Dword_little_endian: == Type_Dword */ case Type_Dword_big_endian: return TRUE; diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 072a4a63c7..866108c7c0 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -27,7 +27,6 @@ #pragma hdrstop #endif -#include "wx/window.h" #include "wx/msw/private.h" // Mingw32 is a bit mental even though this is done in winundef @@ -47,6 +46,8 @@ #include "wx/treectrl.h" #include "wx/settings.h" +#include "wx/msw/dragimag.h" + #ifdef __GNUWIN32_OLD__ #include "wx/msw/gnuwin32/extra.h" #endif @@ -236,11 +237,24 @@ private: wxTreeItemData *m_data; }; +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +static HTREEITEM GetItemFromPoint(HWND hwndTV, int x, int y) +{ + TVHITTESTINFO tvht; + tvht.pt.x = x; + tvht.pt.y = y; + + return TreeView_HitTest(hwndTV, &tvht); +} + // ---------------------------------------------------------------------------- // macros // ---------------------------------------------------------------------------- - IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) +IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) // ---------------------------------------------------------------------------- // variables @@ -298,6 +312,7 @@ void wxTreeCtrl::Init() m_imageListState = NULL; m_textCtrl = NULL; m_hasAnyAttr = FALSE; + m_dragImage = NULL; } bool wxTreeCtrl::Create(wxWindow *parent, @@ -1462,6 +1477,62 @@ bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id) return TRUE; } +// we hook into WndProc to process WM_MOUSEMOVE/WM_BUTTONUP messages - as we +// only do it during dragging, minimize wxWin overhead (this is important for +// WM_MOUSEMOVE as they're a lot of them) by catching Windows messages directly +// instead of passing by wxWin events +long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +{ + if ( m_dragImage ) + { + switch ( nMsg ) + { + case WM_MOUSEMOVE: + { + int x = GET_X_LPARAM(lParam), + y = GET_Y_LPARAM(lParam); + + m_dragImage->Move(wxPoint(x, y), this); + + HTREEITEM htiTarget = GetItemFromPoint(GetHwnd(), x, y); + if ( htiTarget ) + { + // highlight the item as target (hiding drag image is + // necessary - otherwise the display will be corrupted) + m_dragImage->Hide(this); + TreeView_SelectDropTarget(GetHwnd(), htiTarget); + m_dragImage->Show(this); + } + } + break; + + case WM_LBUTTONUP: + case WM_RBUTTONUP: + { + m_dragImage->EndDrag(this); + delete m_dragImage; + m_dragImage = NULL; + + // generate the drag end event + wxTreeEvent event(wxEVT_COMMAND_TREE_END_DRAG, m_windowId); + + int x = GET_X_LPARAM(lParam), + y = GET_Y_LPARAM(lParam); + + event.m_item + = (WXHTREEITEM)GetItemFromPoint(GetHwnd(), x, y); + event.m_pointDrag = wxPoint(x, y); + event.SetEventObject(this); + + (void)GetEventHandler()->ProcessEvent(event); + } + break; + } + } + + return wxControl::MSWWindowProc(nMsg, wParam, lParam); +} + // process WM_NOTIFY Windows message bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { @@ -1504,6 +1575,11 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) event.m_item = (WXHTREEITEM) tv->itemNew.hItem; event.m_pointDrag = wxPoint(tv->ptDrag.x, tv->ptDrag.y); + + // don't allow dragging by default: the user code must + // explicitly say that it wants to allow it to avoid breaking + // the old apps + event.Veto(); } break; @@ -1736,6 +1812,20 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // post processing switch ( hdr->code ) { + case TVN_BEGINDRAG: + case TVN_BEGINRDRAG: + if ( event.IsAllowed() ) + { + // normally this is impossible because the m_dragImage is + // deleted once the drag operation is over + wxASSERT_MSG( !m_dragImage, _T("starting to drag once again?") ); + + m_dragImage = new wxDragImage(*this, event.m_item); + m_dragImage->BeginDrag(wxPoint(0, 0), this); + m_dragImage->Show(this); + } + break; + case TVN_DELETEITEM: { // NB: we might process this message using wxWindows event