Author: gedmurphy
Date: Thu Mar 23 22:27:38 2006
New Revision: 21373
URL:
http://svn.reactos.ru/svn/reactos?rev=21373&view=rev
Log:
Add the floating windows and anchor them the the main window if moved
Added:
trunk/reactos/base/applications/imagesoft/buttons.h
Modified:
trunk/reactos/base/applications/imagesoft/En.rc
trunk/reactos/base/applications/imagesoft/floattoolbar.c
trunk/reactos/base/applications/imagesoft/imagesoft.c
trunk/reactos/base/applications/imagesoft/imagesoft.rc
trunk/reactos/base/applications/imagesoft/imgedwnd.c
trunk/reactos/base/applications/imagesoft/mainwnd.c
trunk/reactos/base/applications/imagesoft/precomp.h
trunk/reactos/base/applications/imagesoft/resource.h
Modified: trunk/reactos/base/applications/imagesoft/En.rc
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/En.rc (original)
+++ trunk/reactos/base/applications/imagesoft/En.rc Thu Mar 23 22:27:38 2006
@@ -117,38 +117,16 @@
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 */
Added: trunk/reactos/base/applications/imagesoft/buttons.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/buttons.h (added)
+++ trunk/reactos/base/applications/imagesoft/buttons.h Thu Mar 23 22:27:38 2006
@@ -1,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},
+};
Modified: trunk/reactos/base/applications/imagesoft/floattoolbar.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/floattoolbar.c (original)
+++ trunk/reactos/base/applications/imagesoft/floattoolbar.c Thu Mar 23 22:27:38 2006
@@ -1,6 +1,8 @@
-#include "precomp.h"
+#include <precomp.h>
static const TCHAR szFloatWndClass[] = TEXT("ImageSoftFloatWndClass");
+
+
BOOL
ShowHideToolbar(HWND hwnd)
@@ -39,12 +41,11 @@
}
break;*/
+ case WM_NCACTIVATE:
+ return DefWindowProc(hwnd, Message, TRUE, lParam);
+
case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
-
- case WM_DESTROY:
- PostQuitMessage(0);
+ ShowHideToolbar(hwnd);
break;
default:
Modified: trunk/reactos/base/applications/imagesoft/imagesoft.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imagesoft.c (original)
+++ trunk/reactos/base/applications/imagesoft/imagesoft.c Thu Mar 23 22:27:38 2006
@@ -1,4 +1,4 @@
-#include <precomp.h>
+#include "precomp.h"
HINSTANCE hInstance;
HANDLE ProcessHeap;
@@ -12,11 +12,11 @@
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,12 +26,21 @@
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())
{
@@ -41,7 +50,7 @@
{
if (InitFloatWndClass())
{
- hMainWnd = CreateMainWindow(lpAppName,
+ hMainWnd = CreateMainWindow(lpTitle,
nCmdShow);
if (hMainWnd != NULL)
{
Modified: trunk/reactos/base/applications/imagesoft/imagesoft.rc
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imagesoft.rc (original)
+++ trunk/reactos/base/applications/imagesoft/imagesoft.rc Thu Mar 23 22:27:38 2006
@@ -5,11 +5,17 @@
#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"
Modified: trunk/reactos/base/applications/imagesoft/imgedwnd.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/imgedwnd.c (original)
+++ trunk/reactos/base/applications/imagesoft/imgedwnd.c Thu Mar 23 22:27:38 2006
@@ -40,7 +40,6 @@
PBITMAPINFO pbmi = NULL;
PBYTE pBits;
HANDLE hFile;
- HDC hDC;
BITMAP bitmap;
Info->Zoom = 100;
@@ -51,24 +50,6 @@
{
/* 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
{
Modified: trunk/reactos/base/applications/imagesoft/mainwnd.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/mainwnd.c (original)
+++ trunk/reactos/base/applications/imagesoft/mainwnd.c Thu Mar 23 22:27:38 2006
@@ -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 @@
{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 @@
}
}
+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;
-
- /* create the 'tools' toolbar */
- /*Info->hFloatTools = CreateDialog(hInstance,
- MAKEINTRESOURCE(IDD_FLOATTOOLS),
- Info->hSelf,
- FloatToolbarWndProc);*/
-
-
- 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);
+ UINT Res, NumButtons = 2;
+ INT i = 0;
+
+ 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;
+ }
+
+
+ /* 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 @@
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,
@@ -425,9 +499,6 @@
(LPARAM)&StdButtons);
}
-
-
- /* other floating toolbars may include colours, history and layers */
}
@@ -767,6 +838,8 @@
{
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,8 +858,37 @@
HIWORD(lParam));
/* NOTE - do *not* forward this message to DefFrameProc! Otherwise the MDI
client
will attempt to resize itself */
- break;
- }
+
+ /* 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:
{
@@ -870,6 +972,10 @@
/* Show the window */
ShowWindow(hwnd,
Info->nCmdShow);
+
+ /* get the windows position */
+ GetWindowRect(hwnd,
+ &wndOldPos);
break;
}
Modified: trunk/reactos/base/applications/imagesoft/precomp.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/precomp.h (original)
+++ trunk/reactos/base/applications/imagesoft/precomp.h Thu Mar 23 22:27:38 2006
@@ -331,13 +331,19 @@
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 */
Modified: trunk/reactos/base/applications/imagesoft/resource.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/base/applications/imagesoft…
==============================================================================
--- trunk/reactos/base/applications/imagesoft/resource.h (original)
+++ trunk/reactos/base/applications/imagesoft/resource.h Thu Mar 23 22:27:38 2006
@@ -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 */