]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cocoa/private/scrollview.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / cocoa / private / scrollview.h
CommitLineData
19253261 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/cocoa/private/scrollview.h
19253261
DE
3// Purpose: wxWindowCocoaScrollView
4// Author: David Elliott
5// Modified by:
6// Created: 2008/02/14
19253261 7// Copyright: (c) 2003- David Elliott
526954c5 8// Licence: wxWindows licence
19253261
DE
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_COCOA_SCROLLVIEW_H__
12#define _WX_COCOA_SCROLLVIEW_H__
13
14@class NSScroller;
15
16// ========================================================================
17// wxWindowCocoaScrollView
18// ========================================================================
19class wxWindowCocoaScrollView: protected wxCocoaNSView
20{
c0c133e1 21 wxDECLARE_NO_COPY_CLASS(wxWindowCocoaScrollView);
19253261
DE
22public:
23 wxWindowCocoaScrollView(wxWindow *owner);
24 virtual ~wxWindowCocoaScrollView();
25 inline WX_NSScrollView GetNSScrollView() { return m_cocoaNSScrollView; }
26 void ClientSizeToSize(int &width, int &height);
27 void DoGetClientSize(int *x, int *y) const;
28 void Encapsulate();
29 void Unencapsulate();
30
31 // wxWindow calls this to do the work. Note that we don't have the refresh parameter
32 // because wxWindow handles that itself.
33 void SetScrollbar(int orientation, int position, int thumbSize, int range);
34 int GetScrollPos(wxOrientation orient);
35 void SetScrollPos(wxOrientation orient, int position);
36 int GetScrollRange(wxOrientation orient);
37 int GetScrollThumb(wxOrientation orient);
38 void ScrollWindow(int dx, int dy, const wxRect*);
39 void UpdateSizes();
40
41 void _wx_doScroller(NSScroller *sender);
42
43protected:
44 wxWindowCocoa *m_owner;
45 WX_NSScrollView m_cocoaNSScrollView;
46 virtual void Cocoa_FrameChanged(void);
47 virtual void Cocoa_synthesizeMouseMoved(void) {}
48 /*!
49 Flag as to whether we're scrolling for a native view or a custom
4c51a665 50 wxWindow. This controls the scrolling behaviour. When providing
19253261
DE
51 scrolling for a native view we don't catch scroller action messages
52 and thus don't send scroll events and we don't actually scroll the
53 window when the application calls ScrollWindow.
54
55 When providing scrolling for a custom wxWindow, we make the NSScroller
56 send their action messages to us which we in turn package as wx window
57 scrolling events. At this point, the window will not physically be
58 scrolled. The application will most likely handle the event by calling
59 ScrollWindow which will do the real scrolling. On the other hand,
60 the application may instead not call ScrollWindow until some threshold
61 is reached. This causes the window to only scroll in steps which is
62 what, for instance, wxScrolledWindow does.
63 */
64 bool m_isNativeView;
65 /*!
66 The range as the application code wishes to see it. That is, the
67 range from the last SetScrollbar call for the appropriate dimension.
68 The horizontal dimension is the first [0] element and the vertical
69 dimension the second [1] element.
70
71 In wxMSW, a SCROLLINFO with nMin=0 and nMax=range-1 is used which
72 gives exactly range possible positions so long as nPage (which is
73 the thumb size) is less than or equal to 1.
74 */
75 int m_scrollRange[2];
76 /*!
77 The thumb size is intended to reflect the size of the visible portion
78 of the scrolled document. As the document size increases, the thumb
79 visible thumb size decreases. As document size decreases, the visible
80 thumb size increases. However, the thumb size on wx is defined in
81 terms of scroll units (which are effectively defined by the scroll
82 range) and so increasing the number of scroll units to reflect increased
83 document size will have the effect of decreasing the visible thumb
84 size even though the number doesn't change.
85
86 It's also important to note that subtracting the thumb size from the
87 full range gives you the real range that can be used. Microsoft
88 defines nPos (the current scrolling position) to be within the range
89 from nMin to nMax - max(nPage - 1, 0). We know that wxMSW code always
90 sets nMin = 0 and nMax = range -1. So let's algebraically reduce the
91 definition of the maximum allowed position:
92
93 Begin:
94 = nMax - max(nPage - 1, 0)
95 Substitute (range - 1) for nMax and thumbSize for nPage:
96 = range - 1 - max(thumbSize - 1, 0)
97 Add one inside the max conditional and subtract one outside of it:
98 = range - 1 - (max(thumbSize - 1 + 1, 1) - 1)
99 Reduce some constants:
100 = range - 1 - (max(thumbSize, 1) - 1)
101 Distribute the negative across the parenthesis:
102 = range - 1 - max(thumbSize, 1) + 1
103 Reduce the constants:
104 = range - max(thumbSize, 1)
105
106 Also keep in mind that thumbSize may never be greater than range but
107 can be equal to it. Thus for the smallest possible thumbSize there
108 are exactly range possible scroll positions (numbered from 0 to
109 range - 1) and for the largest possible thumbSize there is exactly
110 one possible scroll position (numbered 0).
111 */
112 int m_scrollThumb[2];
113
114 /*!
115 The origin of the virtual coordinate space expressed in terms of client
116 coordinates. Starts at (0,0) and each call to ScrollWindow accumulates
117 into it. Thus if the user scrolls the window right (thus causing the
118 contents to move left with respect to the client origin, the
119 application code (typically wxScrolledWindow) will be called with
120 dx of -something, for example -20. This is added to m_virtualOrigin
121 and thus m_virtualOrigin will be (-20,0) in this example.
122 */
123 wxPoint m_virtualOrigin;
124private:
125 wxWindowCocoaScrollView();
126};
127
128#endif //ndef _WX_COCOA_SCROLLVIEW_H__