even more funny icon arrangements

svn path=/trunk/; revision=7787
This commit is contained in:
Martin Fuchs 2004-01-20 19:07:28 +00:00
parent 0d1556f869
commit 90db7f8c36
9 changed files with 139 additions and 38 deletions

View file

@ -291,9 +291,9 @@ DesktopShellView::DesktopShellView(HWND hwnd, IShellView* pShellView)
// subclass background window
new BackgroundWindow(_hwndListView);
_alignment = 0;
_icon_algo = 0;
PositionIcons(_alignment);
PositionIcons();
InitDragDrop();
}
@ -336,11 +336,14 @@ LRESULT DesktopShellView::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
DoDesktopContextMenu(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam));
break;
case PM_POSITION_ICONS:
PositionIcons(wparam);
_alignment = wparam;
case PM_SET_ICON_ALGORITHM:
_icon_algo = wparam;
PositionIcons();
break;
case PM_GET_ICON_ALGORITHM:
return _icon_algo;
default:
return super::WndProc(nmsg, wparam, lparam);
}
@ -442,7 +445,11 @@ HRESULT DesktopShellView::DoDesktopContextMenu(int x, int y)
}
static const POINTS s_align_start[8] = {
#define ARRANGE_BORDER_DOWN 8
#define ARRANGE_BORDER_HV 9
#define ARRANGE_ROUNDABOUT 10
static const POINTS s_align_start[] = {
{0, 0}, // left/top
{0, 0},
{1, 0}, // right/top
@ -450,10 +457,14 @@ static const POINTS s_align_start[8] = {
{0, 1}, // left/bottom
{0, 1},
{1, 1}, // right/bottom
{1, 1}
{1, 1},
{0, 0}, // left/top
{0, 0},
{0, 0}
};
static const POINTS s_align_dir1[8] = {
static const POINTS s_align_dir1[] = {
{ 0, +1}, // down
{+1, 0}, // right
{-1, 0}, // left
@ -461,10 +472,14 @@ static const POINTS s_align_dir1[8] = {
{ 0, -1}, // up
{+1, 0}, // right
{-1, 0}, // left
{ 0, -1} // up
{ 0, -1}, // up
{ 0, +1}, // down
{+1, 0}, // right
{+1, 0} // right
};
static const POINTS s_align_dir2[8] = {
static const POINTS s_align_dir2[] = {
{+1, 0}, // right
{ 0, +1}, // down
{ 0, +1}, // down
@ -472,22 +487,26 @@ static const POINTS s_align_dir2[8] = {
{+1, 0}, // right
{ 0, -1}, // up
{ 0, -1}, // up
{-1, 0} // left
{-1, 0}, // left
{+1, 0}, // right
{ 0, +1}, // down
{ 0, +1} // down
};
typedef pair<int,int> IconPos;
typedef map<IconPos, int> IconMap;
void DesktopShellView::PositionIcons(int alignment, int dir)
void DesktopShellView::PositionIcons(int dir)
{
DWORD spacing = ListView_GetItemSpacing(_hwndListView, FALSE);
RECT work_area;
SystemParametersInfo(SPI_GETWORKAREA, 0, &work_area, 0);
const POINTS& dir1 = s_align_dir1[alignment];
const POINTS& dir2 = s_align_dir2[alignment];
const POINTS& start_pos = s_align_start[alignment];
const POINTS& dir1 = s_align_dir1[_icon_algo];
const POINTS& dir2 = s_align_dir2[_icon_algo];
const POINTS& start_pos = s_align_start[_icon_algo];
int dir_x1 = dir1.x;
int dir_y1 = dir1.y;
@ -502,8 +521,8 @@ void DesktopShellView::PositionIcons(int alignment, int dir)
int dx2 = dir_x2 * cx;
int dy2 = dir_y2 * cy;
int start_x = start_pos.x * work_area.right + (cx-32)/2;
int start_y = start_pos.y * work_area.bottom + 4/*(cy-32)/2*/;
int start_x = (start_pos.x * work_area.right)/cx*cx + (cx-32)/2;
int start_y = (start_pos.y * work_area.bottom)/cy*cy + 4/*(cy-32)/2*/;
if (start_x >= work_area.right)
start_x -= cx;
@ -514,22 +533,64 @@ void DesktopShellView::PositionIcons(int alignment, int dir)
int x = start_x;
int y = start_y;
int cnt = ListView_GetItemCount(_hwndListView);
int all = ListView_GetItemCount(_hwndListView);
int i1, i2;
if (dir > 0) {
i1 = 0;
i2 = cnt;
i2 = all;
} else {
i1 = cnt-1;
i1 = all-1;
i2 = -1;
}
IconMap pos_idx;
int cnt = 0;
for(int idx=i1; idx!=i2; idx+=dir) {
pos_idx[IconPos(y, x)] = idx;
if (_icon_algo == ARRANGE_BORDER_DOWN) {
if (++cnt & 1)
x = work_area.right - x;
else {
y += dy1;
if (y >= work_area.bottom) {
y = start_y;
x += dx2;
}
}
continue;
}
else if (_icon_algo == ARRANGE_BORDER_HV) {
if (++cnt & 1)
x = work_area.right - x;
else if (cnt & 2) {
y += dy1;
if (y >= work_area.bottom) {
y = start_y;
x += dx2;
}
} else {
x += dx1;
if (x >= work_area.right) {
x = start_x;
y += dy2;
}
}
continue;
}
else if (_icon_algo == ARRANGE_ROUNDABOUT) {
///@todo
}
x += dx1;
y += dy1;
@ -542,6 +603,8 @@ void DesktopShellView::PositionIcons(int alignment, int dir)
}
}
// use a little trick to get the icons where we want them to be...
for(IconMap::const_iterator it=pos_idx.end(); --it!=pos_idx.begin(); ) {
const IconPos& pos = it->first;

View file

@ -26,7 +26,8 @@
//
#define PM_POSITION_ICONS (WM_APP+0x19)
#define PM_SET_ICON_ALGORITHM (WM_APP+0x19)
#define PM_GET_ICON_ALGORITHM (WM_APP+0x1A)
/// subclassed Background window behind the visible desktop window
@ -176,9 +177,9 @@ protected:
bool DoContextMenu(int x, int y);
HRESULT DoDesktopContextMenu(int x, int y);
void PositionIcons(int alignment, int dir=1);
void PositionIcons(int dir=1);
DesktopDropTarget* _pDropTarget;
HWND _hwndListView;
int _alignment;
int _icon_algo;
};

View file

@ -75,7 +75,10 @@ DesktopSettingsDlg::DesktopSettingsDlg(HWND hwnd)
_bmp4(IDB_ICON_ALIGN_4),
_bmp5(IDB_ICON_ALIGN_5),
_bmp6(IDB_ICON_ALIGN_6),
_bmp7(IDB_ICON_ALIGN_7)
_bmp7(IDB_ICON_ALIGN_7),
_bmp8(IDB_ICON_ALIGN_8),
_bmp9(IDB_ICON_ALIGN_9),
_bmp10(IDB_ICON_ALIGN_10)
{
new PictureButton(_hwnd, IDC_ICON_ALIGN_0, _bmp0);
new PictureButton(_hwnd, IDC_ICON_ALIGN_1, _bmp1);
@ -85,8 +88,12 @@ DesktopSettingsDlg::DesktopSettingsDlg(HWND hwnd)
new PictureButton(_hwnd, IDC_ICON_ALIGN_5, _bmp5);
new PictureButton(_hwnd, IDC_ICON_ALIGN_6, _bmp6);
new PictureButton(_hwnd, IDC_ICON_ALIGN_7, _bmp7);
new PictureButton(_hwnd, IDC_ICON_ALIGN_8, _bmp8);
new PictureButton(_hwnd, IDC_ICON_ALIGN_9, _bmp9);
new PictureButton(_hwnd, IDC_ICON_ALIGN_10, _bmp10);
_alignment = 0;
_alignment_cur = SendMessage(g_Globals._hwndShellView, PM_GET_ICON_ALGORITHM, 0, 0);
_alignment_tmp = _alignment_cur;
}
#ifndef PSN_QUERYINITIALFOCUS // currently (as of 18.01.2004) missing in MinGW headers
@ -97,7 +104,16 @@ int DesktopSettingsDlg::Notify(int id, NMHDR* pnmh)
{
switch(pnmh->code) {
case PSN_QUERYINITIALFOCUS:
SetWindowLong(_hwnd, DWL_MSGRESULT, (LPARAM)GetDlgItem(_hwnd, IDC_ICON_ALIGN_0+_alignment));
SetWindowLong(_hwnd, DWL_MSGRESULT, (LPARAM)GetDlgItem(_hwnd, IDC_ICON_ALIGN_0+_alignment_cur));
break;
case PSN_APPLY:
_alignment_cur = _alignment_tmp;
break;
case PSN_RESET:
if (_alignment_tmp != _alignment_cur)
SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, _alignment_cur, 0);
break;
default:
@ -109,15 +125,15 @@ int DesktopSettingsDlg::Notify(int id, NMHDR* pnmh)
int DesktopSettingsDlg::Command(int id, int code)
{
if (id>=IDC_ICON_ALIGN_0 && id<=IDC_ICON_ALIGN_7) {
if (id>=IDC_ICON_ALIGN_0 && id<=IDC_ICON_ALIGN_10) {
int alignment = id - IDC_ICON_ALIGN_0;
if (alignment != _alignment) {
_alignment = alignment;
if (alignment != _alignment_tmp) {
_alignment_tmp = alignment;
PropSheet_Changed(GetParent(_hwnd), _hwnd);
SendMessage(g_Globals._hwndShellView, PM_POSITION_ICONS, alignment, 0);
SendMessage(g_Globals._hwndShellView, PM_SET_ICON_ALGORITHM, alignment, 0);
}
}

View file

@ -47,8 +47,12 @@ protected:
ResBitmap _bmp5;
ResBitmap _bmp6;
ResBitmap _bmp7;
ResBitmap _bmp8;
ResBitmap _bmp9;
ResBitmap _bmp10;
int _alignment;
int _alignment_cur;
int _alignment_tmp;
virtual int Command(int id, int code);
virtual int Notify(int id, NMHDR* pnmh);

View file

@ -83,6 +83,9 @@
#define IDB_ICON_ALIGN_5 158
#define IDB_ICON_ALIGN_6 159
#define IDB_ICON_ALIGN_7 160
#define IDB_ICON_ALIGN_8 161
#define IDB_ICON_ALIGN_9 162
#define IDB_ICON_ALIGN_10 163
#define ID_VIEW_NAME 401
#define ID_VIEW_ALL_ATTRIBUTES 402
#define ID_VIEW_SELECTED_ATTRIBUTES 403
@ -90,7 +93,6 @@
#define ID_VIEW_DRIVE_BAR 507
#define ID_VIEW_TOOL_BAR 508
#define IDC_ROS_EXPLORER 1000
#define IDC_BUTTON1 1002
#define IDC_ICON_ALIGN_0 1002
#define IDC_ICON_ALIGN_1 1003
#define IDC_ICON_ALIGN_2 1004
@ -99,7 +101,11 @@
#define IDC_ICON_ALIGN_5 1007
#define IDC_ICON_ALIGN_6 1008
#define IDC_ICON_ALIGN_7 1009
#define IDC_ICON_ALIGN_8 1010
#define IDC_ICON_ALIGN_9 1011
#define IDC_ICON_ALIGN_10 1012
#define IDC_WWW 1012
#define IDC_ICON_ALIGN_11 1013
#define IDC_TOPIC 1017
#define IDC_MAILS_FOUND 1018
#define ID_REFRESH 1704

View file

@ -374,6 +374,9 @@ IDB_ICON_ALIGN_4 BITMAP DISCARDABLE "res/icoalig4.bmp"
IDB_ICON_ALIGN_5 BITMAP DISCARDABLE "res/icoalig5.bmp"
IDB_ICON_ALIGN_6 BITMAP DISCARDABLE "res/icoalig6.bmp"
IDB_ICON_ALIGN_7 BITMAP DISCARDABLE "res/icoalig7.bmp"
IDB_ICON_ALIGN_8 BITMAP DISCARDABLE "res/icoalig8.bmp"
IDB_ICON_ALIGN_9 BITMAP DISCARDABLE "res/icoalig9.bmp"
IDB_ICON_ALIGN_10 BITMAP DISCARDABLE "res/icoali10.bmp"
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
@ -700,7 +703,7 @@ BEGIN
WS_TABSTOP,7,25,130,33
END
IDD_DESKBAR_DESKTOP DIALOG DISCARDABLE 0, 0, 210, 154
IDD_DESKBAR_DESKTOP DIALOG DISCARDABLE 0, 0, 210, 170
STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
CAPTION "Desktop Properties"
FONT 8, "MS Sans Serif"
@ -716,13 +719,21 @@ BEGIN
CONTROL "rig./top dwn",IDC_ICON_ALIGN_3,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,159,25,44,41
CONTROL "left/bot. up",IDC_ICON_ALIGN_4,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,7,76,44,41
BS_BOTTOM | WS_TABSTOP,7,72,44,41
CONTROL "left/bot. right",IDC_ICON_ALIGN_5,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,56,76,44,41
BS_BOTTOM | WS_TABSTOP,56,72,44,41
CONTROL "right/bot. left",IDC_ICON_ALIGN_6,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,111,76,44,41
BS_BOTTOM | WS_TABSTOP,111,72,44,41
CONTROL "rig./bot. dwn",IDC_ICON_ALIGN_7,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,159,76,44,41
BS_BOTTOM | WS_TABSTOP,159,72,44,41
CONTROL "border down",IDC_ICON_ALIGN_8,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,7,122,44,41
CONTROL "border H/V",IDC_ICON_ALIGN_9,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,56,122,44,41
CONTROL "round about",IDC_ICON_ALIGN_10,"Button",BS_OWNERDRAW |
BS_BOTTOM | WS_TABSTOP,111,122,44,41
CONTROL "",IDC_ICON_ALIGN_11,"Button",BS_OWNERDRAW | BS_BOTTOM |
WS_TABSTOP,159,122,44,41
END
IDD_DESKBAR_TASKBAR DIALOG DISCARDABLE 0, 0, 210, 154
@ -761,7 +772,7 @@ BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 203
TOPMARGIN, 7
BOTTOMMARGIN, 147
BOTTOMMARGIN, 163
END
IDD_DESKBAR_TASKBAR, DIALOG

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB