OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
draglist.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of TDragList
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9
10#include <owl/draglist.h>
11
12namespace owl {
13
15
16// Let the compiler know that the following template instances will be defined elsewhere.
17//#pragma option -Jgx
18
19DEFINE_RESPONSE_TABLE1(TDragList, TListBox)
22
23//
24/// Constructor for creating a drag list dynamically.
25//
26TDragList::TDragList(TWindow* parent, int id, int x, int y, int w, int h,
27 TModule* module)
28:
29 TListBox(parent, id, x, y, w, h, module)
30{
31}
32
33//
34/// Constructor for creating a drag list from a resource.
35//
37:
38 TListBox(parent, resourceId, module)
39{
40}
41
42//
43/// SetupWindow for the drag listbox must call MakeDragList().
44//
45void
51
52//
53/// Handle the DRAGLISTMSGSTRING notification by calling virtual functions
54/// based on the notification message.
55//
56/// Responds to the DL_BEGINDRAG, DL_DRAGGING, DL_DROPPED, and DL_CANCELDRAG
57/// messages by calling the BeginDrag, Dragging, Dropped, and CancelDrag functions
58/// respectively.
59//
61TDragList::DragNotify(TParam1, TParam2 lp)
62{
63 DRAGLISTINFO * info = reinterpret_cast<DRAGLISTINFO *>(lp);
64 if (info) {
65 TPoint p = info->ptCursor;
66 int item = ItemFromPoint(p);
67
68 switch (info->uNotification) {
69 case DL_BEGINDRAG:
70 return BeginDrag(item, p);
71
72 case DL_DRAGGING:
73 return Dragging(item, p);
74
75 case DL_DROPPED:
76 Dropped(item, p);
77 break;
78
79 case DL_CANCELDRAG:
80 CancelDrag(item, p);
81 break;
82
83 default:
84 // Should not ever happen.
85 ///TH perhaps throw an exception?
86 break;
87 }
88 }
89 return 0;
90}
91
92//
93/// The drag UI has started. Return true to allow drag.
94//
95bool
97{
98 return false;
99}
100
101//
102/// User has moved the mouse. Return the type of cursor to represent the allowable
103/// action.
104//
107{
108 return dlStop;
109}
110
111//
112/// User has dropped the item.
113//
114void
116{
117}
118
119//
120/// User has cancelled the drag.
121//
122void
124{
125}
126
127//
128/// Draws the drag cursor.
129//
130void
136
137//
138/// Retrieve the item from the specified point. Return -1 if the point is not on an
139/// item. 'scroll' determines whether the listbox will scroll if the point is above
140/// or below the listbox.
141//
142int
144{
146 return LBItemFromPt(GetHandle(), p, scroll);
147}
148
149//----------------------------------------------------------------------------
150
152 EV_REGISTERED(DRAGLISTMSGSTRING, DragNotify),
154
155//
156/// Forward the drag notification messages from the parent window
157/// to the drag listbox for it to handle.
158//
161{
162 DRAGLISTINFO* info = reinterpret_cast<DRAGLISTINFO*>(lp);
163 if (!info) return 0;
164
165 // Forward messages from parent to listbox.
166 //
167 return ::SendMessage(info->hWnd, ::RegisterWindowMessage(DRAGLISTMSGSTRING), wp, lp);
168}
169
170} // OWL namespace
171/* ========================================================================== */
172
#define PRECONDITION(condition)
Definition checks.h:227
A TEventHandler mix-in.
Definition draglist.h:92
TResult DragNotify(TParam1, TParam2)
Forward the drag notification messages from the parent window to the drag listbox for it to handle.
Definition draglist.cpp:160
TDragList is a draggable list box.
Definition draglist.h:41
void DrawInsert(int item)
Draws the drag cursor.
Definition draglist.cpp:131
virtual void Dropped(int item, const TPoint &point)
User has dropped the item.
Definition draglist.cpp:115
TDragList(TWindow *parent, int id, int x, int y, int w, int h, TModule *module=0)
Constructor for creating a drag list dynamically.
Definition draglist.cpp:26
virtual TCursorType Dragging(int item, const TPoint &point)
User has moved the mouse.
Definition draglist.cpp:106
TCursorType
Enumeration used to specify the type of cursor to be displayed during a drag operation.
Definition draglist.h:49
@ dlStop
stop cursor - item cannot be dropped now
Definition draglist.h:50
virtual void CancelDrag(int item, const TPoint &point)
User has cancelled the drag.
Definition draglist.cpp:123
int ItemFromPoint(const TPoint &p, bool scroll=true)
Retrieve the item from the specified point.
Definition draglist.cpp:143
virtual bool BeginDrag(int item, const TPoint &point)
The drag UI has started. Return true to allow drag.
Definition draglist.cpp:96
void SetupWindow() override
SetupWindow for the drag listbox must call MakeDragList().
Definition draglist.cpp:46
TEventHandler is a base class from which you can derive classes that handle messages.
Definition eventhan.h:162
An interface object that represents a corresponding list box element.
Definition listbox.h:43
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TWindow * GetParent() const
Retrieves the OWL object of the parent window. If none exists, returns 0.
Definition window.h:2013
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
Definition window.cpp:2575
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Definition of class TDragList, a listbox that has dragging capabilities for items.
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
OWL_DIAGINFO
Definition animctrl.cpp:14
END_RESPONSE_TABLE
Definition button.cpp:26
LRESULT TResult
Result type.
Definition dispatch.h:52
#define EV_REGISTERED(str, method)
Resonse table entry for a registered message.
Definition windowev.h:122