Add the floating windows and anchor them the the main window if moved

svn path=/trunk/; revision=21373
This commit is contained in:
Ged Murphy
2006-03-23 19:27:38 +00:00
parent 4902277f8c
commit b7c89c9fe6
9 changed files with 232 additions and 113 deletions
+3 -25
View File
@@ -117,38 +117,16 @@ BEGIN
PUSHBUTTON "Cancel", IDCANCEL, 102, 144, 48, 13
END
/* floating toolbar */
IDD_FLOATTOOLS DIALOGEX 1, 17, 32, 112
STYLE WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_VISIBLE
EXSTYLE WS_EX_TOOLWINDOW
CAPTION "Tools"
FONT 8, "MS Sans Serif"
BEGIN
/*
PUSHBUTTON "1", IDC_PRESS,0,0,16,16
PUSHBUTTON "2", IDC_PRESS,16,0,16,16
PUSHBUTTON "3", IDC_PRESS,0,16,16,16
PUSHBUTTON "4", IDC_PRESS,16,16,16,16
PUSHBUTTON "5", IDC_PRESS,0,32,16,16
PUSHBUTTON "6", IDC_PRESS,16,32,16,16
PUSHBUTTON "7", IDC_PRESS,0,48,16,16
PUSHBUTTON "8", IDC_PRESS,16,48,16,16
PUSHBUTTON "9", IDC_PRESS,0,64,16,16
PUSHBUTTON "10", IDC_PRESS,16,64,16,16
*/
END
STRINGTABLE DISCARDABLE
BEGIN
IDS_APPNAME "ImageSoft"
IDS_LICENSE "This program 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 2 of the License, or (at your option) any later version.\r\n\r\nThis program 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.\r\n\r\nYou should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."
IDS_READY " Ready."
IDS_TOOLBAR_STANDARD "Standard"
IDS_TOOLBAR_TEST "Test"
IDS_IMAGE_NAME "Image %1!u!"
IDS_FLT_TOOLS "Tools"
IDS_FLT_COLORS "Colors"
IDS_FLT_HISTORY "History"
END
/* imageprop.c */
@@ -0,0 +1,24 @@
TBBUTTON StdButtons[] = {
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
{TBICON_NEW, ID_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* new */
{TBICON_OPEN, ID_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* open */
{TBICON_SAVE, ID_SAVE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* save */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_PRINT, ID_PRINTPRE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* print */
{TBICON_PRINTPRE, ID_PRINT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* print preview */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_CUT, ID_CUT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* cut */
{TBICON_COPY, ID_COPY, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* copy */
{TBICON_PASTE, ID_PASTE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* paste */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_UNDO, ID_UNDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* undo */
{TBICON_REDO, ID_REDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* redo */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
};
@@ -1,7 +1,9 @@
#include "precomp.h"
#include <precomp.h>
static const TCHAR szFloatWndClass[] = TEXT("ImageSoftFloatWndClass");
BOOL
ShowHideToolbar(HWND hwnd)
{
@@ -39,12 +41,11 @@ FloatToolbarWndProc(HWND hwnd,
}
break;*/
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_NCACTIVATE:
return DefWindowProc(hwnd, Message, TRUE, lParam);
case WM_DESTROY:
PostQuitMessage(0);
case WM_CLOSE:
ShowHideToolbar(hwnd);
break;
default:
@@ -1,4 +1,4 @@
#include <precomp.h>
#include "precomp.h"
HINSTANCE hInstance;
HANDLE ProcessHeap;
@@ -12,11 +12,11 @@ WinMain(HINSTANCE hThisInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
LPTSTR lpAppName;
LPTSTR lpAppName, lpVersion, lpTitle;
HWND hMainWnd;
MSG Msg;
BOOL bRet;
int Ret = 1;
int Ret = 1, len;
INITCOMMONCONTROLSEX icex;
hInstance = hThisInstance;
@@ -26,13 +26,22 @@ WinMain(HINSTANCE hThisInstance,
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
InitCommonControlsEx(&icex);
if (!AllocAndLoadString(&lpAppName,
hInstance,
IDS_APPNAME))
if (!AllocAndLoadString(&lpAppName, hInstance, IDS_APPNAME) ||
!AllocAndLoadString(&lpVersion, hInstance, IDS_VERSION) )
{
return 1;
}
len = _tcslen(lpAppName) + _tcslen(lpVersion);
lpTitle = HeapAlloc(ProcessHeap,
0,
(len + 2) * sizeof(TCHAR));
wsprintf(lpTitle,
_T("%s %s"),
lpAppName,
lpVersion);
if (TbdInitImpl())
{
if (InitMainWindowImpl())
@@ -41,7 +50,7 @@ WinMain(HINSTANCE hThisInstance,
{
if (InitFloatWndClass())
{
hMainWnd = CreateMainWindow(lpAppName,
hMainWnd = CreateMainWindow(lpTitle,
nCmdShow);
if (hMainWnd != NULL)
{
@@ -5,12 +5,18 @@
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS image editor\0"
#define REACTOS_STR_INTERNAL_NAME "imagesoft\0"
#define REACTOS_STR_ORIGINAL_FILENAME "imagesoft.exe\0"
//#include <reactos/version.rc>
#include <reactos/version.rc>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
1 24 DISCARDABLE "manifest.xml"
STRINGTABLE DISCARDABLE
BEGIN
IDS_APPNAME "ImageSoft"
IDS_VERSION "v0.1"
END
IDI_ICON ICON "res/imagesoft.ico"
IDB_MAINCOPYICON BITMAP DISCARDABLE "res/icons/MainCopyIcon.bmp"
@@ -40,7 +40,6 @@ InitEditWnd(PEDIT_WND_INFO Info)
PBITMAPINFO pbmi = NULL;
PBYTE pBits;
HANDLE hFile;
HDC hDC;
BITMAP bitmap;
Info->Zoom = 100;
@@ -51,24 +50,6 @@ InitEditWnd(PEDIT_WND_INFO Info)
{
/* FIXME: convert this to a DIB Section */
/* set bitmap dimensions */
Info->Width = Info->OpenInfo->New.Width;
Info->Height = Info->OpenInfo->New.Height;
/* create bitmap */
hDC = GetDC(Info->hSelf);
Info->hBitmap = CreateCompatibleBitmap(hDC, Info->Width, Info->Height);
//Info->hDCMem = CreateCompatibleDC(hDC);
ReleaseDC(Info->hSelf, hDC);
if (!Info->hBitmap)
{
DeleteDC(Info->hDCMem);
return FALSE;
}
//SelectObject(Info->hDCMem, Info->hBitmap);
PatBlt(Info->hDCMem, 0, 0, Info->Width, Info->Height, WHITENESS);
}
else
{
+154 -48
View File
@@ -1,9 +1,11 @@
#include <precomp.h>
#include "buttons.h"
static const TCHAR szMainWndClass[] = TEXT("ImageSoftWndClass");
#define ID_MDI_FIRSTCHILD 50000
#define ID_MDI_WINDOWMENU 5
#define NUM_FLT_TB 3
/* menu hints */
static const MENU_HINT MainMenuHintTable[] = {
@@ -25,33 +27,17 @@ static const MENU_HINT SystemMenuHintTable[] = {
{SC_NEXTWINDOW, IDS_HINT_SYS_NEXT},
};
static FLT_TB FloatingToolbar[NUM_FLT_TB] = {
{NULL, NULL, 0, 0, 55, 300},
{NULL, NULL, 0, 0, 200, 200},
{NULL, NULL, 0, 0, 150, 150}
};
/* Standard Toolbar */
#define ID_TOOLBAR_STANDARD 0
static const TCHAR szToolbarStandard[] = TEXT("STANDARD");
static TBBUTTON StdButtons[] = {
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
{TBICON_NEW, ID_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* new */
{TBICON_OPEN, ID_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* open */
{TBICON_SAVE, ID_SAVE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* save */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_PRINT, ID_PRINTPRE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* print */
{TBICON_PRINTPRE, ID_PRINT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* print preview */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_CUT, ID_CUT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* cut */
{TBICON_COPY, ID_COPY, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* copy */
{TBICON_PASTE, ID_PASTE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* paste */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_UNDO, ID_UNDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* undo */
{TBICON_REDO, ID_REDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* redo */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
};
/* Test Toolbar */
#define ID_TOOLBAR_TEST 1
@@ -363,32 +349,120 @@ MainWndToolbarChevronPushed(struct _TOOLBAR_DOCKS *TbDocks,
}
}
static VOID
MainWndMoveFloatingToolbars(HWND hwnd, PRECT wndOldPos)
{
RECT wndNewPos, TbRect;
INT i, xMoved, yMoved;
GetWindowRect(hwnd,
&wndNewPos);
xMoved = wndNewPos.left - wndOldPos->left;
yMoved = wndNewPos.top - wndOldPos->top;
for (i = 0; i < NUM_FLT_TB; i++)
{
GetWindowRect(FloatingToolbar[i].hSelf,
&TbRect);
FloatingToolbar[i].x = TbRect.left + xMoved;
FloatingToolbar[i].y = TbRect.top + yMoved;
MoveWindow(FloatingToolbar[i].hSelf,
FloatingToolbar[i].x,
FloatingToolbar[i].y,
FloatingToolbar[i].Width,
FloatingToolbar[i].Height,
TRUE);
}
CopyMemory(wndOldPos,
&wndNewPos,
sizeof(RECT));
}
static VOID
MainWndResetFloatingToolbars(HWND hwnd)
{
RECT rect;
GetWindowRect(hwnd,
&rect);
/* tools datum */
MoveWindow(FloatingToolbar[0].hSelf,
rect.left + 5,
rect.top + 5,
FloatingToolbar[0].Width,
FloatingToolbar[0].Height,
TRUE);
/* colors datum */
MoveWindow(FloatingToolbar[1].hSelf,
rect.left + 5,
rect.bottom - FloatingToolbar[1].Height - 5,
FloatingToolbar[1].Width,
FloatingToolbar[1].Height,
TRUE);
/* history datum */
MoveWindow(FloatingToolbar[2].hSelf,
rect.right - FloatingToolbar[2].Width - 5,
rect.top + 5,
FloatingToolbar[2].Width,
FloatingToolbar[2].Height,
TRUE);
}
static VOID
MainWndCreateFloatToolbars(PMAIN_WND_INFO Info)
{
RECT rect;
const TBBUTTON *Buttons = NULL;
UINT NumButtons = 2;
UINT Res, NumButtons = 2;
INT i = 0;
/* create the 'tools' toolbar */
/*Info->hFloatTools = CreateDialog(hInstance,
MAKEINTRESOURCE(IDD_FLOATTOOLS),
Info->hSelf,
FloatToolbarWndProc);*/
GetWindowRect(Info->hMdiClient,
&rect);
/* tools datum */
FloatingToolbar[0].x = rect.left + 5;
FloatingToolbar[0].y = rect.top + 5;
/* colors datum */
FloatingToolbar[1].x = rect.left + 5;
FloatingToolbar[1].y = rect.bottom - FloatingToolbar[1].Height - 5;
/* history datum */
FloatingToolbar[2].x = rect.right - FloatingToolbar[2].Width - 5;
FloatingToolbar[2].y = rect.top + 5;
for (Res = IDS_FLT_TOOLS; Res < IDS_FLT_TOOLS + NUM_FLT_TB; Res++, i++)
{
if (! AllocAndLoadString(&FloatingToolbar[i].lpName,
hInstance,
Res))
{
FloatingToolbar[i].lpName = NULL;
}
Info->hFloatTools = CreateWindowEx(WS_EX_TOOLWINDOW,
TEXT("ImageSoftFloatWndClass"),
TEXT("Test"),
WS_POPUPWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_DLGFRAME,
0,
0,
36,
132,
Info->hSelf,
NULL,
hInstance,
NULL);
/* create the 'tools' toolbar */
FloatingToolbar[i].hSelf = CreateWindowEx(WS_EX_TOOLWINDOW,
TEXT("ImageSoftFloatWndClass"),
FloatingToolbar[i].lpName,
WS_POPUPWINDOW | WS_DLGFRAME | WS_VISIBLE,
FloatingToolbar[i].x,
FloatingToolbar[i].y,
FloatingToolbar[i].Width,
FloatingToolbar[i].Height,
Info->hSelf,
NULL,
hInstance,
NULL);
}
if (Info->hFloatTools != NULL)
@@ -414,10 +488,10 @@ MainWndCreateFloatToolbars(PMAIN_WND_INFO Info)
hFloatToolsImageList = InitImageList(2,
IDB_MAINNEWICON);
ImageList_Destroy((HIMAGELIST)SendMessage(Info->hFloatTools,
TB_SETIMAGELIST,
0,
(LPARAM)hFloatToolsImageList));
SendMessage(Info->hFloatTools,
TB_SETIMAGELIST,
0,
(LPARAM)hFloatToolsImageList);
SendMessage(Info->hFloatTools,
TB_ADDBUTTONS,
@@ -426,9 +500,6 @@ MainWndCreateFloatToolbars(PMAIN_WND_INFO Info)
}
/* other floating toolbars may include colours, history and layers */
}
@@ -767,6 +838,8 @@ MainWndProc(HWND hwnd,
{
PMAIN_WND_INFO Info;
LRESULT Ret = 0;
static BOOL bLBMouseDown = FALSE;
static RECT wndOldPos;
/* Get the window context */
Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd,
@@ -785,9 +858,38 @@ MainWndProc(HWND hwnd,
HIWORD(lParam));
/* NOTE - do *not* forward this message to DefFrameProc! Otherwise the MDI client
will attempt to resize itself */
/* reposition the floating toolbars */
if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED))
MainWndResetFloatingToolbars(Info->hMdiClient);
break;
}
case WM_NCLBUTTONDOWN:
bLBMouseDown = TRUE;
DefWindowProc(hwnd,
uMsg,
wParam,
lParam);
break;
case WM_NCLBUTTONUP :
bLBMouseDown = FALSE;
DefWindowProc(hwnd,
uMsg,
wParam,
lParam);
break;
case WM_MOVE:
{
/* if the main window is moved, move the toolbars too */
if (bLBMouseDown)
MainWndMoveFloatingToolbars(hwnd, &wndOldPos);
}
break;
case WM_NOTIFY:
{
if (!TbdHandleNotifications(&Info->ToolDocks,
@@ -871,6 +973,10 @@ MainWndProc(HWND hwnd,
ShowWindow(hwnd,
Info->nCmdShow);
/* get the windows position */
GetWindowRect(hwnd,
&wndOldPos);
break;
}
+11 -5
View File
@@ -331,13 +331,19 @@ VOID FileInitialize(HWND hwnd);
BOOL DoOpenFile(HWND hwnd, LPTSTR lpFileName, LPTSTR lpName);
BOOL DoSaveFile(HWND hwnd);
/* floating toolbars */
/* floattoolbar.c */
typedef struct _FLT_TB
{
HWND hSelf;
LPTSTR lpName;
INT x;
INT y;
INT Width;
INT Height;
} FLT_TB, *PFLT_TB;
BOOL InitFloatWndClass(VOID);
VOID UninitFloatWndImpl(VOID);
/*LRESULT CALLBACK FloatToolbarWndProc(HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam);*/
BOOL ShowHideToolbar(HWND hwnd);
#endif /* __IMAGESOFT_PRECOMP_H */
+10 -2
View File
@@ -60,6 +60,11 @@
#define IDI_ICON 50
#define IDB_BUTTONS 51
/* these need to be kept consecutive */
#define IDS_FLT_TOOLS 60
#define IDS_FLT_COLORS 61
#define IDS_FLT_HISTORY 62
/* toolbar buttons */
#define TBICON_PROP 0
#define TBICON_REFRESH 1
@@ -77,8 +82,9 @@
#define IDC_LICENSE_EDIT 201
#define IDS_APPNAME 101
#define IDS_LICENSE 102
#define IDS_READY 103
#define IDS_VERSION 102
#define IDS_LICENSE 103
#define IDS_READY 104
#define IDS_TOOLBAR_STANDARD 201
#define IDS_TOOLBAR_TEST 202
#define IDS_IMAGE_NAME 203
@@ -121,6 +127,8 @@
#define IDS_UNIT_KB 4110
/* toolbar buttons resources
* these must be numbered consecutively
* see loop in InitImageList */