2011-11-22 21:28:15 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 GPL Source Code
|
2011-12-06 18:20:15 +00:00
|
|
|
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
|
2011-11-22 21:28:15 +00:00
|
|
|
|
2011-12-06 16:14:59 +00:00
|
|
|
This file is part of the Doom 3 GPL Source Code ("Doom 3 Source Code").
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
Doom 3 Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../../idlib/precompiled.h"
|
|
|
|
#pragma hdrstop
|
|
|
|
|
|
|
|
#include "../../sys/win32/win_local.h"
|
|
|
|
#include "RollupPanel.h"
|
|
|
|
|
|
|
|
// Based on original code by Johann Nadalutti
|
|
|
|
|
|
|
|
#define RP_PGBUTTONHEIGHT 18
|
|
|
|
#define RP_SCROLLBARWIDTH 6
|
|
|
|
#define RP_GRPBOXINDENT 6
|
|
|
|
#define RP_SCROLLBARCOLOR RGB(150,180,180)
|
|
|
|
#define RP_ROLLCURSOR MAKEINTRESOURCE(32649) // see IDC_HAND (WINVER >= 0x0500)
|
|
|
|
|
|
|
|
//Popup Menu Ids
|
|
|
|
#define RP_IDM_EXPANDALL 0x100
|
|
|
|
#define RP_IDM_COLLAPSEALL 0x101
|
|
|
|
#define RP_IDM_STARTITEMS 0x102
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
idList<HWND> rvRollupPanel::mDialogs;
|
2011-11-22 21:28:15 +00:00
|
|
|
HHOOK rvRollupPanel::mDialogHook = NULL;
|
|
|
|
|
|
|
|
#define DEFERPOS
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::rvRollupPanel
|
|
|
|
|
|
|
|
constructor
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
rvRollupPanel::rvRollupPanel ( void )
|
|
|
|
{
|
|
|
|
mStartYPos = 0;
|
|
|
|
mItemHeight = 0;
|
|
|
|
mWindow = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::~rvRollupPanel
|
|
|
|
|
|
|
|
destructor
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
rvRollupPanel::~rvRollupPanel ( void )
|
|
|
|
{
|
|
|
|
// destroy the items
|
|
|
|
for ( ; mItems.Num(); )
|
|
|
|
{
|
|
|
|
_RemoveItem ( 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::Create
|
|
|
|
|
|
|
|
Create the rollup panel window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
bool rvRollupPanel::Create ( DWORD dwStyle, const RECT& rect, HWND parent, unsigned int id )
|
|
|
|
{
|
|
|
|
WNDCLASSEX wndClass;
|
|
|
|
memset ( &wndClass, 0, sizeof(wndClass) );
|
|
|
|
wndClass.cbSize = sizeof(WNDCLASSEX);
|
|
|
|
wndClass.lpszClassName = "ROLLUP_PANEL";
|
|
|
|
wndClass.lpfnWndProc = WindowProc;
|
2011-12-06 18:20:15 +00:00
|
|
|
wndClass.hbrBackground = (HBRUSH)GetSysColorBrush ( COLOR_3DFACE );
|
|
|
|
wndClass.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
2011-11-22 21:28:15 +00:00
|
|
|
wndClass.lpszMenuName = NULL;
|
2011-12-06 18:20:15 +00:00
|
|
|
wndClass.hInstance = win32.hInstance;
|
2011-11-22 21:28:15 +00:00
|
|
|
wndClass.style = CS_VREDRAW | CS_HREDRAW;
|
|
|
|
RegisterClassEx ( &wndClass );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
mWindow = CreateWindowEx ( WS_EX_TOOLWINDOW,
|
|
|
|
"ROLLUP_PANEL",
|
|
|
|
"",
|
|
|
|
dwStyle|WS_CLIPSIBLINGS,
|
2011-11-22 21:28:15 +00:00
|
|
|
rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top,
|
2011-12-06 18:20:15 +00:00
|
|
|
parent,
|
|
|
|
NULL,
|
|
|
|
win32.hInstance,
|
2011-11-22 21:28:15 +00:00
|
|
|
this );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( !mWindow )
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
return true;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::InsertItem
|
|
|
|
|
|
|
|
Insert and item into the rollup panel. Return -1 if an error occured
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvRollupPanel::InsertItem ( const char* caption, HWND dialog, bool autoDestroy, int index )
|
|
|
|
{
|
|
|
|
assert ( caption );
|
|
|
|
assert ( dialog );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// -1 means add to the end
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( index > 0 && index >= mItems.Num() )
|
|
|
|
{
|
|
|
|
index = -1;
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Get client rect
|
2011-11-22 21:28:15 +00:00
|
|
|
RECT r;
|
|
|
|
GetClientRect(mWindow,&r);
|
|
|
|
|
|
|
|
// Create the GroupBox control
|
2011-12-06 18:20:15 +00:00
|
|
|
HWND groupbox = CreateWindow ( "BUTTON", "", WS_CHILD|BS_GROUPBOX,
|
2011-11-22 21:28:15 +00:00
|
|
|
r.left, r.top, r.right-r.left, r.bottom-r.top,
|
|
|
|
mWindow, 0, win32.hInstance, NULL );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// Create the expand button
|
2011-12-06 18:20:15 +00:00
|
|
|
HWND button = CreateWindow ( "BUTTON", caption, WS_CHILD|BS_AUTOCHECKBOX|BS_PUSHLIKE|BS_FLAT,
|
2011-11-22 21:28:15 +00:00
|
|
|
r.left, r.top, r.right-r.left, r.bottom-r.top,
|
|
|
|
mWindow, 0, win32.hInstance, NULL );
|
|
|
|
|
|
|
|
// Change the button's font
|
|
|
|
SendMessage ( button, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0 );
|
|
|
|
|
|
|
|
// Add item to the item list
|
2011-12-06 18:20:15 +00:00
|
|
|
RPITEM* item = new RPITEM;
|
2011-11-22 21:28:15 +00:00
|
|
|
item->mExpanded = false;
|
|
|
|
item->mEnable = true;
|
|
|
|
item->mDialog = dialog;
|
|
|
|
item->mButton = button;
|
|
|
|
item->mGroupBox = groupbox;
|
|
|
|
item->mOldDlgProc = (WNDPROC) GetWindowLong ( dialog, DWL_DLGPROC );
|
|
|
|
item->mOldButtonProc = (WNDPROC) GetWindowLong ( button, GWL_WNDPROC );
|
|
|
|
item->mAutoDestroy = autoDestroy;
|
|
|
|
strcpy ( item->mCaption, caption );
|
|
|
|
|
|
|
|
if ( index < 0 )
|
|
|
|
{
|
|
|
|
index = mItems.Append ( item );
|
|
|
|
}
|
|
|
|
else
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
mItems.Insert ( item, index );
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
// Store data with the dialog window in its user data
|
2011-11-22 21:28:15 +00:00
|
|
|
SetWindowLong ( dialog, GWL_USERDATA, (LONG)item );
|
|
|
|
|
|
|
|
// Attach item to button through user data
|
|
|
|
SetWindowLong ( button, GWL_USERDATA, (LONG)item );
|
|
|
|
SetWindowLong ( button, GWL_ID, index );
|
|
|
|
|
|
|
|
// Subclass dialog
|
|
|
|
SetWindowLong ( dialog, DWL_DLGPROC, (LONG)DialogProc );
|
|
|
|
|
|
|
|
// SubClass button
|
|
|
|
SetWindowLong ( button, GWL_WNDPROC, (LONG)ButtonProc );
|
|
|
|
|
|
|
|
// Update
|
|
|
|
mItemHeight += RP_PGBUTTONHEIGHT+(RP_GRPBOXINDENT/2);
|
|
|
|
RecallLayout ( );
|
|
|
|
|
|
|
|
// One hook for all panel dialogs
|
|
|
|
if ( !mDialogHook )
|
|
|
|
{
|
|
|
|
mDialogHook = SetWindowsHookEx( WH_GETMESSAGE, GetMsgProc, NULL, GetCurrentThreadId() );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mDialogs.Append ( dialog );
|
|
|
|
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::RemoveItem
|
|
|
|
|
|
|
|
Remove the item at the given index from the rollup panel
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::RemoveItem ( int index )
|
|
|
|
{
|
|
|
|
// safety check
|
|
|
|
if ( index >= mItems.Num() || index < 0 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove the item
|
|
|
|
_RemoveItem( index );
|
|
|
|
|
|
|
|
// update the layout
|
2011-12-06 18:20:15 +00:00
|
|
|
RecallLayout ( );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::RemoveAllItems
|
|
|
|
|
|
|
|
Remove all items from the control
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::RemoveAllItems()
|
|
|
|
{
|
|
|
|
for ( ; mItems.Num(); )
|
|
|
|
{
|
|
|
|
_RemoveItem ( 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
// update layout
|
|
|
|
RecallLayout ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::_RemoveItem
|
|
|
|
|
|
|
|
called by RemoveItem and RemoveAllItems methods to acutally remove the item
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::_RemoveItem ( int index )
|
|
|
|
{
|
|
|
|
RPITEM* item = mItems[index];
|
|
|
|
|
|
|
|
// get the item rect
|
|
|
|
RECT ir;
|
|
|
|
GetWindowRect ( item->mDialog, &ir );
|
|
|
|
|
|
|
|
// update item height
|
|
|
|
mItemHeight -= RP_PGBUTTONHEIGHT+(RP_GRPBOXINDENT/2);
|
|
|
|
if ( item->mExpanded )
|
|
|
|
{
|
|
|
|
mItemHeight -= (ir.bottom-ir.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
// destroy windows
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( item->mButton )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
DestroyWindow ( item->mButton );
|
|
|
|
}
|
|
|
|
if ( item->mGroupBox )
|
|
|
|
{
|
|
|
|
DestroyWindow ( item->mGroupBox );
|
|
|
|
}
|
|
|
|
if ( item->mDialog && item->mAutoDestroy )
|
|
|
|
{
|
|
|
|
DestroyWindow ( item->mDialog );
|
2011-12-06 18:20:15 +00:00
|
|
|
mDialogs.Remove ( item->mDialog );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( mDialogs.Num () <= 0 )
|
|
|
|
{
|
|
|
|
UnhookWindowsHookEx( mDialogHook );
|
|
|
|
mDialogHook = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// finish up
|
|
|
|
mItems.RemoveIndex ( index );
|
2011-12-06 18:20:15 +00:00
|
|
|
delete item;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::ExpandItem
|
|
|
|
|
|
|
|
expand or collapse the item at the given index
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::ExpandItem( int index, bool expand )
|
|
|
|
{
|
|
|
|
// safety check
|
|
|
|
if ( index >= mItems.Num() || index < 0 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_ExpandItem ( mItems[index], expand );
|
|
|
|
|
|
|
|
RecallLayout ( );
|
|
|
|
|
|
|
|
// scroll to this page (automatic page visibility)
|
|
|
|
if ( expand )
|
|
|
|
{
|
|
|
|
ScrollToItem ( index, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::ExpandItem
|
|
|
|
|
|
|
|
expand or collapse the item at the given index
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::ExpandAllItems( bool expand )
|
|
|
|
{
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// expand all items
|
|
|
|
for ( i=0; i < mItems.Num(); i ++ )
|
|
|
|
{
|
|
|
|
_ExpandItem ( mItems[i], expand );
|
|
|
|
}
|
|
|
|
|
|
|
|
RecallLayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::ExpandItem
|
|
|
|
|
|
|
|
expand or collapse the item at the given index
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::_ExpandItem ( RPITEM* item, bool expand )
|
|
|
|
{
|
|
|
|
// check if we need to change state
|
|
|
|
if ( item->mExpanded == expand || !item->mEnable )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RECT ir;
|
|
|
|
GetWindowRect ( item->mDialog, &ir );
|
|
|
|
|
|
|
|
// Expand-collapse
|
|
|
|
item->mExpanded = expand;
|
|
|
|
|
|
|
|
if ( expand )
|
|
|
|
{
|
|
|
|
mItemHeight += (ir.bottom - ir.top);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mItemHeight -= (ir.bottom - ir.top);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::EnableItem
|
|
|
|
|
|
|
|
enable/disable the item at the given index
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::EnableItem ( int index, bool enable )
|
|
|
|
{
|
|
|
|
// safety check
|
|
|
|
if ( index >= mItems.Num() || index < 0 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_EnableItem ( mItems[index], enable );
|
|
|
|
RecallLayout ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::EnableAllItems
|
|
|
|
|
|
|
|
enable/disable all items in the panel
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::EnableAllItems ( bool enable )
|
|
|
|
{
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
for ( i=0; i < mItems.Num(); i++ )
|
|
|
|
{
|
|
|
|
_EnableItem ( mItems[i], enable );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
RecallLayout ( );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::_EnableItem
|
|
|
|
|
|
|
|
Called by EnableItem and EnableAllItems to do the work of enabling/disablgin
|
|
|
|
the window
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::_EnableItem ( RPITEM* item, bool enable )
|
|
|
|
{
|
|
|
|
// check if we need to change state
|
|
|
|
if ( item->mEnable == enable )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RECT ir;
|
|
|
|
GetWindowRect ( item->mDialog, &ir );
|
|
|
|
|
|
|
|
item->mEnable = enable;
|
|
|
|
|
|
|
|
if ( item->mExpanded )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
|
|
|
mItemHeight -= (ir.bottom-ir.top);
|
2011-11-22 21:28:15 +00:00
|
|
|
item->mExpanded = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::ScrollToItem
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
Scroll a page at the top of the Rollup Panel if top = true or just ensure
|
|
|
|
item visibility into view if top = false
|
2011-11-22 21:28:15 +00:00
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::ScrollToItem ( int index, bool top )
|
|
|
|
{
|
|
|
|
// safety check
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( index >= mItems.Num() || index < 0 )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RPITEM* item = mItems[index];
|
|
|
|
|
|
|
|
// get rects
|
|
|
|
RECT r;
|
|
|
|
RECT ir;
|
|
|
|
GetWindowRect ( mWindow, &r );
|
|
|
|
GetWindowRect ( item->mDialog, &ir );
|
|
|
|
|
|
|
|
// check page visibility
|
|
|
|
if ( top || ((ir.bottom > r.bottom) || (ir.top < r.top)))
|
|
|
|
{
|
|
|
|
// compute new mStartYPos
|
|
|
|
GetWindowRect( item->mButton, &ir );
|
|
|
|
mStartYPos -= (ir.top-r.top);
|
|
|
|
|
|
|
|
RecallLayout();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::MoveItemAt
|
|
|
|
|
|
|
|
newIndex can be equal to -1 (move at end)
|
|
|
|
return -1 if an error occurs
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvRollupPanel::MoveItemAt ( int index, int newIndex )
|
|
|
|
{
|
|
|
|
if ( index == newIndex || index >= mItems.Num() || index < 0 )
|
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove page from its old position
|
|
|
|
RPITEM* item = mItems[index];
|
|
|
|
mItems.RemoveIndex ( index );
|
|
|
|
|
|
|
|
// insert at its new position
|
|
|
|
if ( newIndex < 0 )
|
|
|
|
{
|
|
|
|
index = mItems.Append( item );
|
|
|
|
}
|
|
|
|
else
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
2011-11-22 21:28:15 +00:00
|
|
|
mItems.Insert ( item, newIndex );
|
|
|
|
index = newIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
RecallLayout ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::RecallLayout
|
|
|
|
|
|
|
|
Update the layout of the control based on current states
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::RecallLayout ( void )
|
|
|
|
{
|
|
|
|
int bottomPagePos;
|
|
|
|
RECT r;
|
|
|
|
int posy;
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
// check StartPosY
|
|
|
|
GetClientRect ( mWindow, &r );
|
|
|
|
bottomPagePos = mStartYPos + mItemHeight;
|
|
|
|
|
|
|
|
if ( bottomPagePos < r.bottom-r.top )
|
|
|
|
{
|
|
|
|
mStartYPos = (r.bottom-r.top) - mItemHeight;
|
|
|
|
}
|
|
|
|
if ( mStartYPos > 0 )
|
|
|
|
{
|
|
|
|
mStartYPos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// update layout
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
2011-11-22 21:28:15 +00:00
|
|
|
HDWP hdwp;
|
|
|
|
hdwp = BeginDeferWindowPos ( mItems.Num() * 3 );
|
|
|
|
#endif
|
|
|
|
posy = mStartYPos;
|
|
|
|
|
|
|
|
for ( i=0; i < mItems.Num(); i++ )
|
|
|
|
{
|
|
|
|
RPITEM* item = mItems[i];
|
|
|
|
|
|
|
|
// enable / disable button
|
|
|
|
SendMessage ( item->mButton, BM_SETCHECK, (item->mEnable&item->mExpanded)?BST_CHECKED:BST_UNCHECKED, 0 );
|
|
|
|
EnableWindow ( item->mButton, item->mEnable );
|
|
|
|
|
|
|
|
// Expanded
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( item->mExpanded && item->mEnable )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
RECT ir;
|
|
|
|
GetWindowRect ( item->mDialog, &ir );
|
|
|
|
|
|
|
|
// update GroupBox position and size
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
|
|
|
DeferWindowPos ( hdwp,
|
2011-11-22 21:28:15 +00:00
|
|
|
#else
|
2011-12-06 18:20:15 +00:00
|
|
|
SetWindowPos (
|
2011-11-22 21:28:15 +00:00
|
|
|
#endif
|
2011-12-06 18:20:15 +00:00
|
|
|
item->mGroupBox, 0, 2, posy,
|
|
|
|
(r.right-r.left)-3-RP_SCROLLBARWIDTH,
|
|
|
|
(ir.bottom-ir.top)+RP_PGBUTTONHEIGHT+RP_GRPBOXINDENT-4,
|
2011-11-22 21:28:15 +00:00
|
|
|
SWP_NOZORDER|SWP_SHOWWINDOW);
|
|
|
|
|
|
|
|
//Update Dialog position and size
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
|
|
|
DeferWindowPos ( hdwp,
|
2011-11-22 21:28:15 +00:00
|
|
|
#else
|
2011-12-06 18:20:15 +00:00
|
|
|
SetWindowPos (
|
2011-11-22 21:28:15 +00:00
|
|
|
#endif
|
2011-12-06 18:20:15 +00:00
|
|
|
item->mDialog, 0, RP_GRPBOXINDENT, posy+RP_PGBUTTONHEIGHT,
|
|
|
|
(r.right-r.left)-RP_SCROLLBARWIDTH-(RP_GRPBOXINDENT*2),
|
2011-11-22 21:28:15 +00:00
|
|
|
ir.bottom-ir.top, SWP_NOZORDER|SWP_SHOWWINDOW);
|
|
|
|
|
|
|
|
//Update Button's position and size
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
|
|
|
DeferWindowPos ( hdwp,
|
2011-11-22 21:28:15 +00:00
|
|
|
#else
|
2011-12-06 18:20:15 +00:00
|
|
|
SetWindowPos (
|
2011-11-22 21:28:15 +00:00
|
|
|
#endif
|
2011-12-06 18:20:15 +00:00
|
|
|
item->mButton, 0, RP_GRPBOXINDENT, posy,
|
|
|
|
(r.right-r.left)-RP_SCROLLBARWIDTH-(RP_GRPBOXINDENT*2),
|
2011-11-22 21:28:15 +00:00
|
|
|
RP_PGBUTTONHEIGHT, SWP_NOZORDER|SWP_SHOWWINDOW);
|
|
|
|
|
|
|
|
posy += (ir.bottom-ir.top) + RP_PGBUTTONHEIGHT;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
// collapsed
|
2011-12-06 18:20:15 +00:00
|
|
|
else
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
// update GroupBox position and size
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
|
|
|
DeferWindowPos ( hdwp,
|
2011-11-22 21:28:15 +00:00
|
|
|
#else
|
2011-12-06 18:20:15 +00:00
|
|
|
SetWindowPos (
|
2011-11-22 21:28:15 +00:00
|
|
|
#endif
|
2011-12-06 18:20:15 +00:00
|
|
|
item->mGroupBox, 0, 2, posy,
|
2011-11-22 21:28:15 +00:00
|
|
|
(r.right-r.left)-3-RP_SCROLLBARWIDTH, 16, SWP_NOZORDER|SWP_SHOWWINDOW);
|
|
|
|
|
|
|
|
// update Dialog position and size
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
|
|
|
DeferWindowPos ( hdwp,
|
2011-11-22 21:28:15 +00:00
|
|
|
#else
|
2011-12-06 18:20:15 +00:00
|
|
|
SetWindowPos (
|
2011-11-22 21:28:15 +00:00
|
|
|
#endif
|
|
|
|
item->mDialog, 0, RP_GRPBOXINDENT, 0, 0, 0,SWP_NOZORDER|SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
|
|
|
|
// update Button's position and size
|
2011-12-06 18:20:15 +00:00
|
|
|
#ifdef DEFERPOS
|
|
|
|
DeferWindowPos ( hdwp,
|
2011-11-22 21:28:15 +00:00
|
|
|
#else
|
2011-12-06 18:20:15 +00:00
|
|
|
SetWindowPos (
|
2011-11-22 21:28:15 +00:00
|
|
|
#endif
|
2011-12-06 18:20:15 +00:00
|
|
|
item->mButton, 0, RP_GRPBOXINDENT, posy,
|
|
|
|
(r.right-r.left)-RP_SCROLLBARWIDTH-(RP_GRPBOXINDENT*2),
|
2011-11-22 21:28:15 +00:00
|
|
|
RP_PGBUTTONHEIGHT, SWP_NOZORDER|SWP_SHOWWINDOW);
|
|
|
|
|
|
|
|
posy += RP_PGBUTTONHEIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
posy += (RP_GRPBOXINDENT/2);
|
|
|
|
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
#ifdef DEFERPOS
|
2011-11-22 21:28:15 +00:00
|
|
|
EndDeferWindowPos ( hdwp );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// update Scroll Bar
|
|
|
|
RECT br;
|
2011-12-06 18:20:15 +00:00
|
|
|
SetRect ( &br, r.right-RP_SCROLLBARWIDTH,r.top,r.right,r.bottom);
|
2011-11-22 21:28:15 +00:00
|
|
|
InvalidateRect( mWindow, &br, FALSE );
|
|
|
|
UpdateWindow ( mWindow );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::GetItemIndex
|
|
|
|
|
|
|
|
Return -1 if no matching item was found, otherwise the index of the item
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvRollupPanel::GetItemIndex ( HWND wnd )
|
|
|
|
{
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
//Search matching button's hwnd
|
|
|
|
for ( i=0; i < mItems.Num(); i++ )
|
|
|
|
{
|
|
|
|
if ( wnd == mItems[i]->mButton )
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int rvRollupPanel::GetItemIndex ( const char* caption )
|
|
|
|
{
|
|
|
|
int i;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
//Search matching button's hwnd
|
|
|
|
for ( i=0; i < mItems.Num(); i++ )
|
|
|
|
{
|
|
|
|
if ( !idStr::Icmp ( caption, mItems[i]->mCaption ) )
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::GetItem
|
|
|
|
|
|
|
|
Return NULL if the index is invalid
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
RPITEM* rvRollupPanel::GetItem ( int index )
|
|
|
|
{
|
|
|
|
// safety check
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( index >= mItems.Num() || index < 0 )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mItems[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::DialogProc
|
|
|
|
|
|
|
|
Dialog procedure for items
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK rvRollupPanel::DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
RPITEM* item = (RPITEM*)GetWindowLong ( hWnd, GWL_USERDATA );
|
|
|
|
rvRollupPanel* _this = (rvRollupPanel*)GetWindowLong ( GetParent ( hWnd ), GWL_USERDATA );
|
|
|
|
|
|
|
|
RECT r;
|
|
|
|
GetClientRect ( _this->mWindow, &r );
|
|
|
|
|
|
|
|
if ( _this->mItemHeight > r.bottom-r.top )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
switch (uMsg)
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
{
|
|
|
|
POINT pos;
|
|
|
|
GetCursorPos ( &pos );
|
|
|
|
_this->mOldMouseYPos = pos.y;
|
|
|
|
::SetCapture(hWnd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
{
|
|
|
|
if ( ::GetCapture() == hWnd )
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
|
|
|
::ReleaseCapture();
|
|
|
|
return 0;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_MOUSEMOVE:
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( (::GetCapture() == hWnd) && (wParam==MK_LBUTTON || wParam==MK_MBUTTON))
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
POINT pos;
|
|
|
|
GetCursorPos(&pos);
|
|
|
|
_this->mStartYPos += (pos.y-_this->mOldMouseYPos);
|
|
|
|
_this->RecallLayout();
|
|
|
|
_this->mOldMouseYPos = pos.y;
|
|
|
|
InvalidateRect ( _this->mWindow, NULL, TRUE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SETCURSOR:
|
|
|
|
if ( (HWND)wParam == hWnd)
|
2011-12-06 18:20:15 +00:00
|
|
|
{
|
|
|
|
SetCursor ( LoadCursor (NULL, RP_ROLLCURSOR) );
|
|
|
|
return TRUE;
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ::CallWindowProc ( item->mOldDlgProc, hWnd, uMsg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::DialogProc
|
|
|
|
|
|
|
|
Button procedure for items
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK rvRollupPanel::ButtonProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
if ( uMsg == WM_SETFOCUS )
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
RPITEM* item = (RPITEM*)GetWindowLong(hWnd, GWL_USERDATA);
|
2011-11-22 21:28:15 +00:00
|
|
|
return ::CallWindowProc( item->mOldButtonProc, hWnd, uMsg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::WindowProc
|
|
|
|
|
|
|
|
Window procedure for rollup panel
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
LRESULT CALLBACK rvRollupPanel::WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
rvRollupPanel* panel;
|
2011-12-06 18:20:15 +00:00
|
|
|
panel = (rvRollupPanel*)GetWindowLong (hWnd, GWL_USERDATA);
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
switch ( uMsg )
|
|
|
|
{
|
|
|
|
case WM_CREATE:
|
|
|
|
{
|
|
|
|
LPCREATESTRUCT cs;
|
|
|
|
|
|
|
|
// Attach the class to the window first
|
|
|
|
cs = (LPCREATESTRUCT) lParam;
|
|
|
|
panel = (rvRollupPanel*) cs->lpCreateParams;
|
|
|
|
SetWindowLong ( hWnd, GWL_USERDATA, (LONG)panel );
|
|
|
|
break;
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
panel->HandleCommand ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_PAINT:
|
2011-12-06 18:20:15 +00:00
|
|
|
return panel->HandlePaint ( wParam, lParam );
|
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_SIZE:
|
|
|
|
return panel->HandleSize ( wParam, lParam );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
panel->HandleLButtonDown ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
panel->HandleLButtonUp ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
panel->HandleMouseMove ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MOUSEWHEEL:
|
|
|
|
panel->HandleMouseWheel ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_MOUSEACTIVATE:
|
|
|
|
panel->HandleMouseActivate ( wParam, lParam );
|
|
|
|
break;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
case WM_CONTEXTMENU:
|
2011-12-06 18:20:15 +00:00
|
|
|
return panel->HandleContextMenu ( wParam, lParam );
|
2011-11-22 21:28:15 +00:00
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return DefWindowProc ( hWnd, uMsg, wParam, lParam );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleCommand
|
|
|
|
|
|
|
|
Handle the WM_COMMAND message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandleCommand ( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
// popup menu command to expand or collapse pages
|
|
|
|
if ( LOWORD(wParam) == RP_IDM_EXPANDALL )
|
|
|
|
{
|
|
|
|
ExpandAllItems ( true );
|
|
|
|
}
|
|
|
|
else if ( LOWORD(wParam) == RP_IDM_COLLAPSEALL )
|
|
|
|
{
|
|
|
|
ExpandAllItems ( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// popupMenu command to expand page
|
2011-12-06 18:20:15 +00:00
|
|
|
else if ( LOWORD(wParam) >= RP_IDM_STARTITEMS &&
|
2011-11-22 21:28:15 +00:00
|
|
|
LOWORD(wParam) < RP_IDM_STARTITEMS + GetItemCount ( ) )
|
|
|
|
{
|
|
|
|
int index = LOWORD(wParam)-RP_IDM_STARTITEMS;
|
|
|
|
ExpandItem ( index, !IsItemExpanded(index) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// button command
|
|
|
|
else if ( HIWORD(wParam) == BN_CLICKED )
|
|
|
|
{
|
|
|
|
int index = GetItemIndex ((HWND)lParam);
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( index != -1 )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
ExpandItem ( index, !IsItemExpanded ( index ) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandlePaint
|
|
|
|
|
|
|
|
Handle the WM_PAINT message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandlePaint( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
HDC dc;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
RECT r;
|
|
|
|
RECT br;
|
|
|
|
int sbPos;
|
|
|
|
int sbSize;
|
|
|
|
int clientHeight;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
dc = BeginPaint ( mWindow, &ps );
|
|
|
|
|
|
|
|
// scrollbar
|
|
|
|
GetClientRect ( mWindow, &r );
|
|
|
|
SetRect ( &br, r.right-RP_SCROLLBARWIDTH, r.top, r.right, r.bottom );
|
|
|
|
DrawEdge ( dc, &br, EDGE_RAISED, BF_RECT );
|
|
|
|
|
|
|
|
sbPos = 0;
|
|
|
|
sbSize = 0;
|
|
|
|
clientHeight = (r.bottom-r.top) - 4;
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( mItemHeight > (r.bottom-r.top) )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
sbSize = clientHeight - (((mItemHeight-(r.bottom-r.top)) * clientHeight ) / mItemHeight );
|
|
|
|
sbPos = -(mStartYPos * clientHeight) / mItemHeight;
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
|
|
|
else
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
sbSize = clientHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
br.left +=2;
|
|
|
|
br.right -=1;
|
|
|
|
br.top = sbPos+2;
|
|
|
|
br.bottom = br.top+sbSize;
|
|
|
|
|
|
|
|
HBRUSH brush;
|
|
|
|
brush = CreateSolidBrush ( RP_SCROLLBARCOLOR );
|
|
|
|
FillRect ( dc, &br, brush );
|
|
|
|
DeleteObject ( brush );
|
|
|
|
|
|
|
|
SetRect ( &r, br.left,2,br.right,br.top );
|
|
|
|
FillRect ( dc, &r, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
|
|
|
|
|
|
|
|
SetRect ( &r, br.left,br.bottom,br.right,2+clientHeight );
|
|
|
|
FillRect ( dc, &r, (HBRUSH)GetStockObject ( BLACK_BRUSH ) );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleSize
|
|
|
|
|
|
|
|
Handle the WM_SIZE message
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvRollupPanel::HandleSize ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
DefWindowProc ( mWindow, WM_SIZE, wParam, lParam );
|
|
|
|
RecallLayout();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleLButtonDown
|
|
|
|
|
|
|
|
Handle the WM_LBUTTONDOWN message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandleLButtonDown ( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
RECT br;
|
|
|
|
POINT point;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
GetClientRect ( mWindow, &r );
|
|
|
|
if ( mItemHeight <= r.bottom - r.top )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
point.x = LOWORD(lParam);
|
|
|
|
point.y = HIWORD(lParam);
|
|
|
|
|
|
|
|
SetRect ( &br, r.right - RP_SCROLLBARWIDTH, r.top, r.right, r.bottom );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( (wParam & MK_LBUTTON) && PtInRect ( &br, point ) )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
SetCapture( mWindow );
|
|
|
|
|
|
|
|
int clientHeight = (r.bottom-r.top) - 4;
|
|
|
|
|
|
|
|
int sbSize = clientHeight - (((mItemHeight - (r.bottom-r.top)) * clientHeight) / mItemHeight );
|
|
|
|
int sbPos = -(mStartYPos * clientHeight) / mItemHeight;
|
|
|
|
|
|
|
|
// click inside scrollbar cursor
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( (point.y < (sbPos + sbSize)) && (point.y > sbPos ))
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
mSBOffset = sbPos - point.y + 1;
|
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
// click outside scrollbar cursor (2 cases => above or below cursor)
|
2011-12-06 18:20:15 +00:00
|
|
|
else
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
int distup = point.y - sbPos;
|
2011-11-22 21:28:15 +00:00
|
|
|
int distdown = (sbPos + sbSize) - point.y;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
if ( distup < distdown )
|
|
|
|
{
|
|
|
|
//above
|
|
|
|
mSBOffset = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//below
|
|
|
|
mSBOffset = -sbSize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// calc new m_nStartYPos from mouse pos
|
|
|
|
int targetPos = point.y + mSBOffset;
|
|
|
|
mStartYPos =- (targetPos * mItemHeight) / clientHeight;
|
|
|
|
|
|
|
|
// update
|
|
|
|
RecallLayout();
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleLButtonUp
|
|
|
|
|
|
|
|
Handle the WM_LBUTTONUP message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandleLButtonUp ( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
if ( GetCapture() == mWindow )
|
|
|
|
{
|
|
|
|
ReleaseCapture();
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleMouseMove
|
|
|
|
|
|
|
|
Handle the WM_MOUSEMOVE message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandleMouseMove ( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
RECT br;
|
|
|
|
POINT point;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
GetClientRect ( mWindow, &r );
|
|
|
|
if ( mItemHeight <= r.bottom - r.top )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
point.x = LOWORD(lParam);
|
|
|
|
point.y = HIWORD(lParam);
|
|
|
|
|
|
|
|
SetRect ( &br, r.right - RP_SCROLLBARWIDTH, r.top, r.right, r.bottom );
|
|
|
|
|
2011-12-06 18:20:15 +00:00
|
|
|
if ( (wParam & MK_LBUTTON) && (GetCapture() == mWindow ))
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
// calc new m_nStartYPos from mouse pos
|
|
|
|
int clientHeight = (r.bottom-r.top) - 4;
|
|
|
|
int targetPos = point.y + mSBOffset;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
mStartYPos =- (targetPos * mItemHeight) / clientHeight;
|
|
|
|
|
|
|
|
RecallLayout ( );
|
2011-12-06 18:20:15 +00:00
|
|
|
|
|
|
|
InvalidateRect ( mWindow, NULL, FALSE );
|
2011-11-22 21:28:15 +00:00
|
|
|
// UpdateWindow ( mWindow );
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleMouseWheel
|
|
|
|
|
|
|
|
Handle the WM_MOUSEWHEEL message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandleMouseWheel ( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
// calc new m_nStartYPos
|
|
|
|
mStartYPos += (HIWORD(wParam) / 4);
|
|
|
|
|
|
|
|
RecallLayout();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleMouseActivate
|
|
|
|
|
|
|
|
Handle the WM_MOUSEACTIVATE message
|
|
|
|
================
|
|
|
|
*/
|
2011-12-06 18:20:15 +00:00
|
|
|
int rvRollupPanel::HandleMouseActivate ( WPARAM wParam, LPARAM lParam )
|
2011-11-22 21:28:15 +00:00
|
|
|
{
|
|
|
|
SetFocus ( mWindow );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::HandleContextMenu
|
|
|
|
|
|
|
|
Handle the WM_CONTEXTMENU message
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int rvRollupPanel::HandleContextMenu ( WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
HMENU menu;
|
|
|
|
int i;
|
|
|
|
POINT point;
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
menu = CreatePopupMenu ( );
|
|
|
|
if ( !menu )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
point.x = LOWORD(lParam);
|
|
|
|
point.y = HIWORD(lParam);
|
|
|
|
|
|
|
|
AppendMenu ( menu, MF_STRING, RP_IDM_EXPANDALL, "Expand all" );
|
|
|
|
AppendMenu ( menu, MF_STRING, RP_IDM_COLLAPSEALL, "Collapse all" );
|
|
|
|
AppendMenu ( menu, MF_SEPARATOR, 0, "" );
|
|
|
|
|
|
|
|
//Add all pages with checked style for expanded ones
|
|
|
|
for ( i=0; i < mItems.Num(); i++ )
|
|
|
|
{
|
|
|
|
char itemName[1024];
|
|
|
|
GetWindowText ( mItems[i]->mButton, itemName, 1023 );
|
2011-12-06 18:20:15 +00:00
|
|
|
AppendMenu ( menu, MF_STRING, RP_IDM_STARTITEMS + i, itemName );
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
if ( mItems[i]->mExpanded )
|
|
|
|
{
|
|
|
|
CheckMenuItem ( menu, RP_IDM_STARTITEMS + i, MF_CHECKED);
|
|
|
|
}
|
|
|
|
|
|
|
|
TrackPopupMenu ( menu, TPM_LEFTALIGN|TPM_LEFTBUTTON, point.x, point.y, 0, mWindow, NULL );
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::GetMsgProc
|
|
|
|
|
|
|
|
Ensures normal dialog functions work in the alpha select dialog
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
LRESULT FAR PASCAL rvRollupPanel::GetMsgProc ( int nCode, WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
LPMSG lpMsg = (LPMSG) lParam;
|
|
|
|
|
|
|
|
if ( nCode >= 0 && PM_REMOVE == wParam )
|
|
|
|
{
|
|
|
|
// Don't translate non-input events.
|
|
|
|
if ( (lpMsg->message >= WM_KEYFIRST && lpMsg->message <= WM_KEYLAST) )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for ( i = 0; i < mDialogs.Num(); i ++ )
|
|
|
|
{
|
|
|
|
if ( IsDialogMessage( mDialogs[i], lpMsg) )
|
|
|
|
{
|
2011-12-06 18:20:15 +00:00
|
|
|
// The value returned from this hookproc is ignored,
|
2011-11-22 21:28:15 +00:00
|
|
|
// and it cannot be used to tell Windows the message has been handled.
|
2011-12-06 18:20:15 +00:00
|
|
|
// To avoid further processing, convert the message to WM_NULL
|
2011-11-22 21:28:15 +00:00
|
|
|
// before returning.
|
|
|
|
lpMsg->message = WM_NULL;
|
|
|
|
lpMsg->lParam = 0;
|
|
|
|
lpMsg->wParam = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallNextHookEx ( mDialogHook, nCode, wParam, lParam);
|
2011-12-06 18:20:15 +00:00
|
|
|
}
|
2011-11-22 21:28:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
rvRollupPanel::AutoSize
|
|
|
|
|
|
|
|
Automatically set the width of the control based on the dialogs it contains
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
void rvRollupPanel::AutoSize ( void )
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int width = 0;
|
|
|
|
for ( i = 0; i < mItems.Num(); i ++ )
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
int w;
|
|
|
|
GetWindowRect ( mItems[i]->mDialog, &r );
|
|
|
|
w = (r.right-r.left)+RP_SCROLLBARWIDTH+(RP_GRPBOXINDENT*2);
|
|
|
|
if ( w > width )
|
|
|
|
{
|
|
|
|
width = w;
|
|
|
|
}
|
|
|
|
}
|
2011-12-06 18:20:15 +00:00
|
|
|
|
2011-11-22 21:28:15 +00:00
|
|
|
RECT cr;
|
|
|
|
GetWindowRect ( mWindow, &cr );
|
|
|
|
SetWindowPos ( mWindow, NULL, 0, 0, width, cr.bottom-cr.top, SWP_NOMOVE|SWP_NOZORDER );
|
|
|
|
}
|