Update of /cvsroot/perl-win32-gui/Win32-GUI
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13775
Modified Files:
CHANGELOG GUI.xs
Log Message:
Improve Scroll() method to be easier to maintain, update docs and code to match
Index: GUI.xs
===================================================================
RCS file: /cvsroot/perl-win32-gui/Win32-GUI/GUI.xs,v
retrieving revision 1.64
retrieving revision 1.65
diff -C2 -d -r1.64 -r1.65
*** GUI.xs 20 Jan 2007 17:09:22 -0000 1.64
--- GUI.xs 15 Jul 2007 19:01:15 -0000 1.65
***************
*** 1291,1301 ****
###########################################################################
! # (@)METHOD:Scroll(scrollbar,operation,position[,SB_THUMBTRACK_flag])
# Handles scrollbar scrolling if you don't want to do it yourself. This is
# most useful in the Scroll event handler for a window or dialog box.
#
# B<scrollbar> can be:
! # 0 : Horizontal scrollbar
! # 1 : Vertical scrollbar
#
# B<operation> is an identifier for the operation being performed on the
--- 1291,1301 ----
###########################################################################
! # (@)METHOD:Scroll(scrollbar,operation[,position, [thumbtrack_flag]])
# Handles scrollbar scrolling if you don't want to do it yourself. This is
# most useful in the Scroll event handler for a window or dialog box.
#
# B<scrollbar> can be:
! # SB_HOR(0) : Horizontal scrollbar
! # SB_VERT(1) : Vertical scrollbar
#
# B<operation> is an identifier for the operation being performed on the
***************
*** 1305,1320 ****
# SB_THUMBTRACK, SB_TOP, SB_LEFT, SB_BOTTOM, SB_RIGHT, or SB_ENDSCROLL
#
! # Returns the position of the scrollbar or undef on failure.
#
! DWORD
! Scroll(handle, scrollbar, operation, position, ... )
HWND handle
! int scrollbar
! int operation
! int position
PREINIT:
SCROLLINFO si;
CODE:
! si.cbSize = sizeof(SCROLLINFO);
si.fMask = SIF_ALL;
if(GetScrollInfo(handle,scrollbar,&si)) {
--- 1305,1330 ----
# SB_THUMBTRACK, SB_TOP, SB_LEFT, SB_BOTTOM, SB_RIGHT, or SB_ENDSCROLL
#
! # B<position> is ignored unless B<operation> is SB_THUMBPOSITION, or
! # B<operation> is SB_THUMBTRACK and B<thumbtrack_flag> is TRUE. If
! # B<position> is not provided (or provided and equal to -1), then
! # the position used is taken from the internal scrollbar structure:
! # this is the prefered method of operation.
#
! # B<thumbtrack_flag> indicates whether SB_THUMBTRACK messages are
! # processed (TRUE) or not (FALSE). It defaults to false.
! #
! # Returns the new position of the scrollbar, or undef on failure.
! #
! int
! Scroll(handle, scrollbar, operation, position = -1, thumbtrack_flag = 0)
HWND handle
! int scrollbar
! int operation
! int position
! BOOL thumbtrack_flag
PREINIT:
SCROLLINFO si;
CODE:
! si.cbSize = sizeof(si);
si.fMask = SIF_ALL;
if(GetScrollInfo(handle,scrollbar,&si)) {
***************
*** 1322,1357 ****
switch(operation) {
case SB_THUMBTRACK:
! if (items <= 4 || ! SvIV(ST(4)))
! { break;
}
! /* fall through */
case SB_THUMBPOSITION:
! if (position == -1)
! { si.nPos = si.nTrackPos;
! } else
! { si.nPos = position;
}
! break;
case SB_LINEUP:
si.nPos--;
! break;
case SB_LINEDOWN:
si.nPos++;
! break;
case SB_PAGEUP:
si.nPos -= si.nPage;
! break;
case SB_PAGEDOWN:
si.nPos += si.nPage;
! break;
case SB_TOP:
si.nPos = si.nMin;
! break;
case SB_BOTTOM:
si.nPos = si.nMax;
! break;
}
RETVAL = SetScrollInfo(handle, scrollbar, &si, 1);
}
OUTPUT:
RETVAL
--- 1332,1375 ----
switch(operation) {
case SB_THUMBTRACK:
! if(!thumbtrack_flag) {
! /* No tracking */
! break;
}
! /* fall through */
case SB_THUMBPOSITION:
! if(position == -1) {
! si.nPos = si.nTrackPos;
}
! else {
! si.nPos = position;
! }
! break;
case SB_LINEUP:
si.nPos--;
! break;
case SB_LINEDOWN:
si.nPos++;
! break;
case SB_PAGEUP:
si.nPos -= si.nPage;
! break;
case SB_PAGEDOWN:
si.nPos += si.nPage;
! break;
case SB_TOP:
si.nPos = si.nMin;
! break;
case SB_BOTTOM:
si.nPos = si.nMax;
! break;
! default:
! XSRETURN_UNDEF;
! break;
}
RETVAL = SetScrollInfo(handle, scrollbar, &si, 1);
}
+ else {
+ XSRETURN_UNDEF;
+ }
OUTPUT:
RETVAL
***************
*** 1818,1822 ****
###########################################################################
# (@)INTERNAL:_UserData()
! # Return a reference to an HV, stored in the perlud.UserData member
# of the PERLWIN32GUI_USERDATA struct
HV *
--- 1836,1840 ----
###########################################################################
# (@)INTERNAL:_UserData()
! # Return a reference to an HV, stored in the perlud.userData member
# of the PERLWIN32GUI_USERDATA struct
HV *
Index: CHANGELOG
===================================================================
RCS file: /cvsroot/perl-win32-gui/Win32-GUI/CHANGELOG,v
retrieving revision 1.118
retrieving revision 1.119
diff -C2 -d -r1.118 -r1.119
*** CHANGELOG 15 Jul 2007 18:58:28 -0000 1.118
--- CHANGELOG 15 Jul 2007 19:01:15 -0000 1.119
***************
*** 23,26 ****
--- 23,28 ----
- TYPEMAP - correct UINT to be T_UV
- Toolbar.xs - LoadImages() correct typo in docs
+ - GUI.xs - tidy up the implementation of the Scroll() function, make it
+ really return UNDEF on failure, and improve documentation.
+ [Robert May] : 20 January 2007 - Restore Original WndProc