- Fix drawing onto loaded bitmaps.

- Don't call CreateCompatibleDC for each paint
- Make the floating windows translucent unless the cursor is over them
- Put in some temp code for basic sketches. (this functionality needs incorporating into separate tool functions)
- change the internal name 'floating toolbars' to 'floating windows' to avoid confusion.

svn path=/trunk/; revision=21376
This commit is contained in:
Ged Murphy 2006-03-24 19:39:07 +00:00
parent 5e4fc1d4c3
commit e3342f0b3e
17 changed files with 435 additions and 199 deletions

View file

@ -33,6 +33,8 @@ BEGIN
POPUP "&View" POPUP "&View"
BEGIN BEGIN
MENUITEM "&Tools", ID_TOOLS, CHECKED MENUITEM "&Tools", ID_TOOLS, CHECKED
MENUITEM "&Color", -1, CHECKED
MENUITEM "&History", -1, CHECKED
MENUITEM "&Status Bar", ID_STATUSBAR, CHECKED MENUITEM "&Status Bar", ID_STATUSBAR, CHECKED
END END
POPUP "&Image" POPUP "&Image"

View file

@ -1,5 +1,6 @@
TBBUTTON StdButtons[] = {
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
TBBUTTON StdButtons[] = {
{TBICON_NEW, ID_NEW, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* new */ {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_OPEN, ID_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* open */
{TBICON_SAVE, ID_SAVE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* save */ {TBICON_SAVE, ID_SAVE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* save */
@ -22,3 +23,17 @@ TBBUTTON StdButtons[] = {
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, {10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
}; };
TBBUTTON TextButtons[] = {
{TBICON_BOLD, ID_BOLD, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* bold */
{TBICON_ITALIC, ID_ITALIC, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* italic */
{TBICON_ULINE, ID_ULINE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* underline */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_TXTLEFT, ID_TXTLEFT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* left justified */
{TBICON_TXTCENTER,ID_TXTCENTER,TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* centered */
{TBICON_TXTRIGHT, ID_TXTRIGHT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* right justified */
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
};

View file

@ -1,87 +0,0 @@
#include <precomp.h>
static const TCHAR szFloatWndClass[] = TEXT("ImageSoftFloatWndClass");
BOOL
ShowHideToolbar(HWND hwnd)
{
static BOOL Hidden = FALSE;
ShowWindow(hwnd, Hidden ? SW_SHOW : SW_HIDE);
Hidden = ~Hidden;
return Hidden;
}
LRESULT CALLBACK
FloatToolbarWndProc(HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam)
{
switch(Message)
{
case WM_CREATE:
break;
/*case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL)
ShowHideToolbar(hwnd);
switch(LOWORD(wParam))
{
case IDC_PRESS:
MessageBox(hwnd, _T("Kapow!"), _T("Hit test"),
MB_OK | MB_ICONEXCLAMATION);
break;
}
break;*/
case WM_NCACTIVATE:
return DefWindowProc(hwnd, Message, TRUE, lParam);
case WM_CLOSE:
ShowHideToolbar(hwnd);
break;
default:
return DefWindowProc(hwnd,
Message,
wParam,
lParam);
}
return 0;
}
BOOL
InitFloatWndClass(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = FloatToolbarWndProc;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,
IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = szFloatWndClass;
wc.hIconSm = NULL;
return RegisterClassEx(&wc) != (ATOM)0;
}
VOID
UninitFloatWndImpl(VOID)
{
UnregisterClass(szFloatWndClass,
hInstance);
}

View file

@ -0,0 +1,169 @@
#include <precomp.h>
static const TCHAR szFloatWndClass[] = TEXT("ImageSoftFloatWndClass");
#define ID_TIMER 1
BOOL
ShowHideWindow(HWND hwnd)
{
static BOOL Hidden = FALSE;
ShowWindow(hwnd, Hidden ? SW_SHOW : SW_HIDE);
Hidden = ~Hidden;
return Hidden;
}
LRESULT CALLBACK
FloatToolbarWndProc(HWND hwnd,
UINT Message,
WPARAM wParam,
LPARAM lParam)
{
switch(Message)
{
static BOOL bOpaque = FALSE;
case WM_CREATE:
SetWindowLong(hwnd,
GWL_EXSTYLE,
GetWindowLong(hwnd,
GWL_EXSTYLE) | WS_EX_LAYERED);
/* set the tranclucency to 60% */
SetLayeredWindowAttributes(hwnd,
0,
(255 * 60) / 100,
LWA_ALPHA);
break;
case WM_TIMER:
{
POINT pt;
if (bOpaque != TRUE)
{
KillTimer(hwnd,
ID_TIMER);
break;
}
if (GetCursorPos(&pt))
{
RECT rect;
if (GetWindowRect(hwnd,
&rect))
{
if (! PtInRect(&rect,
pt))
{
KillTimer(hwnd,
ID_TIMER);
bOpaque = FALSE;
SetWindowLong(hwnd,
GWL_EXSTYLE,
GetWindowLong(hwnd,
GWL_EXSTYLE) | WS_EX_LAYERED);
/* set the tranclucency to 60% */
SetLayeredWindowAttributes(hwnd,
0,
(255 * 60) / 100,
LWA_ALPHA);
}
}
}
}
break;
case WM_NCMOUSEMOVE:
case WM_MOUSEMOVE:
if (bOpaque == FALSE)
{
SetWindowLong(hwnd,
GWL_EXSTYLE,
GetWindowLong(hwnd,
GWL_EXSTYLE) & ~WS_EX_LAYERED);
RedrawWindow(hwnd,
NULL,
NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
bOpaque = TRUE;
SetTimer(hwnd,
ID_TIMER,
200,
NULL);
}
break;
case WM_COMMAND:
if (LOWORD(wParam) == IDCANCEL)
ShowHideWindow(hwnd);
switch(LOWORD(wParam))
{
case IDC_PRESS:
MessageBox(hwnd, _T("Kapow!"), _T("Hit test"),
MB_OK | MB_ICONEXCLAMATION);
break;
}
break;
case WM_NCACTIVATE:
/* FIXME: needs fully implementing */
return DefWindowProc(hwnd,
Message,
TRUE,
lParam);
case WM_CLOSE:
ShowHideWindow(hwnd);
break;
default:
return DefWindowProc(hwnd,
Message,
wParam,
lParam);
}
return 0;
}
BOOL
InitFloatWndClass(VOID)
{
WNDCLASSEX wc = {0};
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = FloatToolbarWndProc;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL,
IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszClassName = szFloatWndClass;
wc.hIconSm = NULL;
return RegisterClassEx(&wc) != (ATOM)0;
}
VOID
UninitFloatWndImpl(VOID)
{
UnregisterClass(szFloatWndClass,
hInstance);
}

View file

@ -1,4 +1,4 @@
#include "precomp.h" #include <precomp.h>
HINSTANCE hInstance; HINSTANCE hInstance;
HANDLE ProcessHeap; HANDLE ProcessHeap;

View file

@ -18,7 +18,7 @@
<library>comdlg32</library> <library>comdlg32</library>
<compilationunit name="unit.c"> <compilationunit name="unit.c">
<file>about.c</file> <file>about.c</file>
<file>floattoolbar.c</file> <file>floatwindow.c</file>
<file>imageprop.c</file> <file>imageprop.c</file>
<file>imagesoft.c</file> <file>imagesoft.c</file>
<file>imgedwnd.c</file> <file>imgedwnd.c</file>

View file

@ -30,6 +30,13 @@ IDB_MAINPRINTICON BITMAP DISCARDABLE "res/icons/MainPrintIcon.bmp"
IDB_MAINPRINTPREICON BITMAP DISCARDABLE "res/icons/MainPrintPreIcon.bmp" IDB_MAINPRINTPREICON BITMAP DISCARDABLE "res/icons/MainPrintPreIcon.bmp"
IDB_MAINSAVEICON BITMAP DISCARDABLE "res/icons/MainSaveIcon.bmp" IDB_MAINSAVEICON BITMAP DISCARDABLE "res/icons/MainSaveIcon.bmp"
IDB_TEXTBOLD BITMAP DISCARDABLE "res/icons/TextBoldIcon.bmp"
IDB_TEXTITALIC BITMAP DISCARDABLE "res/icons/TextItalicIcon.bmp"
IDB_TEXTULINE BITMAP DISCARDABLE "res/icons/TextUnderlineIcon.bmp"
IDB_TEXTLEFT BITMAP DISCARDABLE "res/icons/TextAlignLeftIcon.bmp"
IDB_TEXTCENTER BITMAP DISCARDABLE "res/icons/TextAlignCenterIcon.bmp"
IDB_TEXTRIGHT BITMAP DISCARDABLE "res/icons/TextAlignRightIcon.bmp"
IDC_PAINTBRUSHCURSOR CURSOR DISCARDABLE "res/cursors/PaintBrushToolCursor.cur" IDC_PAINTBRUSHCURSOR CURSOR DISCARDABLE "res/cursors/PaintBrushToolCursor.cur"
IDC_PAINTBRUSHCURSORMOUSEDOWN CURSOR DISCARDABLE "res/cursors/PaintBrushToolCursorMouseDown.cur" IDC_PAINTBRUSHCURSORMOUSEDOWN CURSOR DISCARDABLE "res/cursors/PaintBrushToolCursorMouseDown.cur"

View file

@ -46,9 +46,16 @@ InitEditWnd(PEDIT_WND_INFO Info)
if (Info->OpenInfo != NULL) if (Info->OpenInfo != NULL)
{ {
HDC hDC = GetDC(Info->hSelf);
Info->hDCMem = CreateCompatibleDC(hDC);
ReleaseDC(Info->hSelf, hDC);
if (Info->OpenInfo->CreateNew) if (Info->OpenInfo->CreateNew)
{ {
/* FIXME: convert this to a DIB Section */ /* FIXME: convert this to a DIB Section */
/* set bitmap dimensions */
Info->Width = Info->OpenInfo->New.Width;
Info->Height = Info->OpenInfo->New.Height;
} }
else else
@ -157,10 +164,12 @@ InitEditWnd(PEDIT_WND_INFO Info)
fail: fail:
if (! hFile) if (! hFile)
CloseHandle(hFile); CloseHandle(hFile);
if (! pbmi) if (! pbmi)
HeapFree(ProcessHeap, HeapFree(ProcessHeap,
0, 0,
pbmi); pbmi);
return FALSE; return FALSE;
} }
@ -170,6 +179,8 @@ DestroyEditWnd(PEDIT_WND_INFO Info)
PEDIT_WND_INFO *PrevEditor; PEDIT_WND_INFO *PrevEditor;
PEDIT_WND_INFO Editor; PEDIT_WND_INFO Editor;
DeleteDC(Info->hDCMem);
/* FIXME - free resources and run down editor */ /* FIXME - free resources and run down editor */
/* Remove the image editor from the list */ /* Remove the image editor from the list */
@ -196,24 +207,20 @@ ImageEditWndRepaint(PEDIT_WND_INFO Info,
if (Info->hBitmap) if (Info->hBitmap)
{ {
Info->hDCMem = CreateCompatibleDC(hDC);
hOldBitmap = (HBITMAP) SelectObject(Info->hDCMem, hOldBitmap = (HBITMAP) SelectObject(Info->hDCMem,
Info->hBitmap); Info->hBitmap);
BitBlt(hDC, BitBlt(hDC,
0, lpps->rcPaint.left,
0, lpps->rcPaint.top,
Info->Width, lpps->rcPaint.right - lpps->rcPaint.left,
Info->Height, lpps->rcPaint.bottom - lpps->rcPaint.top,
Info->hDCMem, Info->hDCMem,
0, lpps->rcPaint.left,
0, lpps->rcPaint.top,
SRCCOPY); SRCCOPY);
Info->hBitmap = SelectObject(Info->hDCMem, hOldBitmap); Info->hBitmap = SelectObject(Info->hDCMem, hOldBitmap);
DeleteDC(Info->hDCMem);
} }
} }
@ -225,7 +232,9 @@ ImageEditWndProc(HWND hwnd,
{ {
PEDIT_WND_INFO Info; PEDIT_WND_INFO Info;
LRESULT Ret = 0; LRESULT Ret = 0;
static BOOL bLMButtonDown = FALSE; HDC hDC;
static INT xMouse, yMouse;
static BOOL bLeftButtonDown, bRightButtonDown;
/* Get the window context */ /* Get the window context */
Info = (PEDIT_WND_INFO)GetWindowLongPtr(hwnd, Info = (PEDIT_WND_INFO)GetWindowLongPtr(hwnd,
@ -262,24 +271,96 @@ ImageEditWndProc(HWND hwnd,
break; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
if (! bRightButtonDown)
SetCapture(Info->hSelf);
bLeftButtonDown = TRUE;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
SetCursor(LoadCursor(hInstance, SetCursor(LoadCursor(hInstance,
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSORMOUSEDOWN))); MAKEINTRESOURCE(IDC_PAINTBRUSHCURSORMOUSEDOWN)));
bLMButtonDown = TRUE;
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
bLMButtonDown = FALSE; if (bLeftButtonDown)
SetCapture(NULL);
bLeftButtonDown = FALSE;
break;
case WM_RBUTTONDOWN:
if (! bLeftButtonDown)
SetCapture(Info->hSelf);
bRightButtonDown = TRUE;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
SetCursor(LoadCursor(hInstance,
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSORMOUSEDOWN)));
break;
case WM_RBUTTONUP:
if (bRightButtonDown)
SetCapture(NULL);
bRightButtonDown = FALSE;
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (bLMButtonDown) {
SetCursor(LoadCursor(hInstance, HPEN hPen, hPenOld;
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSORMOUSEDOWN)));
if (!bLeftButtonDown && !bRightButtonDown)
break;
hDC = GetDC(Info->hSelf);
SelectObject(Info->hDCMem,
Info->hBitmap);
if (bLeftButtonDown)
hPen = CreatePen(PS_SOLID,
3,
RGB(0, 0, 0));
else else
SetCursor(LoadCursor(hInstance, hPen = CreatePen(PS_SOLID,
MAKEINTRESOURCE(IDC_PAINTBRUSHCURSOR))); 3,
RGB(255, 255, 255));
hPenOld = SelectObject(hDC,
hPen);
MoveToEx(hDC,
xMouse,
yMouse,
NULL);
MoveToEx(Info->hDCMem,
xMouse,
yMouse,
NULL);
xMouse = (short)LOWORD(lParam);
yMouse = (short)HIWORD(lParam);
LineTo(hDC,
xMouse,
yMouse);
LineTo(Info->hDCMem,
xMouse,
yMouse);
DeleteObject(SelectObject(hDC,
hPenOld));
ReleaseDC(Info->hSelf,
hDC);
}
break; break;
case WM_PAINT: case WM_PAINT:

View file

@ -5,7 +5,7 @@ static const TCHAR szMainWndClass[] = TEXT("ImageSoftWndClass");
#define ID_MDI_FIRSTCHILD 50000 #define ID_MDI_FIRSTCHILD 50000
#define ID_MDI_WINDOWMENU 5 #define ID_MDI_WINDOWMENU 5
#define NUM_FLT_TB 3 #define NUM_FLT_WND 3
/* menu hints */ /* menu hints */
static const MENU_HINT MainMenuHintTable[] = { static const MENU_HINT MainMenuHintTable[] = {
@ -27,26 +27,29 @@ static const MENU_HINT SystemMenuHintTable[] = {
{SC_NEXTWINDOW, IDS_HINT_SYS_NEXT}, {SC_NEXTWINDOW, IDS_HINT_SYS_NEXT},
}; };
static FLT_TB FloatingToolbar[NUM_FLT_TB] = { static FLT_WND FloatingWindow[NUM_FLT_WND] = {
{NULL, NULL, 0, 0, 55, 300}, {NULL, NULL, 0, 0, 55, 300},
{NULL, NULL, 0, 0, 200, 200}, {NULL, NULL, 0, 0, 200, 200},
{NULL, NULL, 0, 0, 150, 150} {NULL, NULL, 0, 0, 150, 150}
}; };
/* Standard Toolbar */ /* Toolbars */
#define ID_TOOLBAR_STANDARD 0 #define ID_TOOLBAR_STANDARD 0
#define ID_TOOLBAR_TEXT 1
static const TCHAR szToolbarStandard[] = TEXT("STANDARD"); static const TCHAR szToolbarStandard[] = TEXT("STANDARD");
static const TCHAR szToolbarText[] = TEXT("TEXT");
/* Test Toolbar */ /* Test Toolbar */
#define ID_TOOLBAR_TEST 1 #define ID_TOOLBAR_TEST 5
static const TCHAR szToolbarTest[] = TEXT("TEST"); static const TCHAR szToolbarTest[] = TEXT("TEST");
/* Toolbars table */ /* Toolbars table */
static const DOCKBAR MainDockBars[] = { static const DOCKBAR MainDockBars[] = {
{ID_TOOLBAR_STANDARD, szToolbarStandard, IDS_TOOLBAR_STANDARD, TOP_DOCK}, {ID_TOOLBAR_STANDARD, szToolbarStandard, IDS_TOOLBAR_STANDARD, TOP_DOCK},
{ID_TOOLBAR_TEST, szToolbarTest, IDS_TOOLBAR_TEST, TOP_DOCK}, {ID_TOOLBAR_TEST, szToolbarTest, IDS_TOOLBAR_TEST, TOP_DOCK},
{ID_TOOLBAR_TEXT, szToolbarText, IDS_TOOLBAR_TEXT, TOP_DOCK},
}; };
@ -108,6 +111,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
{ {
const TBBUTTON *Buttons = NULL; const TBBUTTON *Buttons = NULL;
UINT NumButtons = 0; UINT NumButtons = 0;
UINT StartImageRes;
HWND hWndClient = NULL; HWND hWndClient = NULL;
UNREFERENCED_PARAMETER(Context); UNREFERENCED_PARAMETER(Context);
@ -119,6 +123,15 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
{ {
Buttons = StdButtons; Buttons = StdButtons;
NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]); NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]);
StartImageRes = IDB_MAINNEWICON;
break;
}
case ID_TOOLBAR_TEXT:
{
Buttons = TextButtons;
NumButtons = sizeof(TextButtons) / sizeof(TextButtons[0]);
StartImageRes = IDB_TEXTBOLD;
break; break;
} }
@ -158,7 +171,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
NULL); NULL);
if (hWndClient != NULL) if (hWndClient != NULL)
{ {
HIMAGELIST hMainTBImageList; HIMAGELIST hImageList;
SendMessage(hWndClient, SendMessage(hWndClient,
TB_SETEXTENDEDSTYLE, TB_SETEXTENDEDSTYLE,
@ -176,18 +189,20 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
0, 0,
(LPARAM)MAKELONG(TB_BMP_WIDTH, TB_BMP_HEIGHT)); (LPARAM)MAKELONG(TB_BMP_WIDTH, TB_BMP_HEIGHT));
hMainTBImageList = InitImageList(NUM_MAINTB_IMAGES, hImageList = InitImageList(NumButtons,
IDB_MAINNEWICON); StartImageRes);
ImageList_Destroy((HIMAGELIST)SendMessage(hWndClient, ImageList_Destroy((HIMAGELIST)SendMessage(hWndClient,
TB_SETIMAGELIST, TB_SETIMAGELIST,
0, 0,
(LPARAM)hMainTBImageList)); (LPARAM)hImageList));
SendMessage(hWndClient, SendMessage(hWndClient,
TB_ADDBUTTONS, TB_ADDBUTTONS,
NumButtons, NumButtons,
(LPARAM)&StdButtons); (LPARAM)Buttons);
} }
} }
@ -224,6 +239,7 @@ MainWndToolbarInsertBand(struct _TOOLBAR_DOCKS *TbDocks,
{ {
switch (rbi->wID) switch (rbi->wID)
{ {
case ID_TOOLBAR_TEXT:
case ID_TOOLBAR_STANDARD: case ID_TOOLBAR_STANDARD:
{ {
SIZE Size; SIZE Size;
@ -273,6 +289,7 @@ MainWndToolbarDockBand(struct _TOOLBAR_DOCKS *TbDocks,
{ {
switch (rbi->wID) switch (rbi->wID)
{ {
case ID_TOOLBAR_TEXT:
case ID_TOOLBAR_STANDARD: case ID_TOOLBAR_STANDARD:
{ {
SIZE Size; SIZE Size;
@ -350,30 +367,31 @@ MainWndToolbarChevronPushed(struct _TOOLBAR_DOCKS *TbDocks,
} }
static VOID static VOID
MainWndMoveFloatingToolbars(HWND hwnd, PRECT wndOldPos) MainWndMoveFloatingWindows(HWND hwnd, PRECT wndOldPos)
{ {
RECT wndNewPos, TbRect; RECT wndNewPos, TbRect;
INT i, xMoved, yMoved; INT i, xMoved, yMoved;
GetWindowRect(hwnd, if (GetWindowRect(hwnd,
&wndNewPos); &wndNewPos))
{
xMoved = wndNewPos.left - wndOldPos->left; xMoved = wndNewPos.left - wndOldPos->left;
yMoved = wndNewPos.top - wndOldPos->top; yMoved = wndNewPos.top - wndOldPos->top;
for (i = 0; i < NUM_FLT_TB; i++) for (i = 0; i < NUM_FLT_WND; i++)
{ {
GetWindowRect(FloatingToolbar[i].hSelf, GetWindowRect(FloatingWindow[i].hSelf,
&TbRect); &TbRect);
FloatingToolbar[i].x = TbRect.left + xMoved; FloatingWindow[i].x = TbRect.left + xMoved;
FloatingToolbar[i].y = TbRect.top + yMoved; FloatingWindow[i].y = TbRect.top + yMoved;
MoveWindow(FloatingToolbar[i].hSelf, MoveWindow(FloatingWindow[i].hSelf,
FloatingToolbar[i].x, FloatingWindow[i].x,
FloatingToolbar[i].y, FloatingWindow[i].y,
FloatingToolbar[i].Width, FloatingWindow[i].Width,
FloatingToolbar[i].Height, FloatingWindow[i].Height,
TRUE); TRUE);
} }
@ -381,83 +399,89 @@ MainWndMoveFloatingToolbars(HWND hwnd, PRECT wndOldPos)
&wndNewPos, &wndNewPos,
sizeof(RECT)); sizeof(RECT));
} }
}
static VOID static VOID
MainWndResetFloatingToolbars(HWND hwnd) MainWndResetFloatingWindows(HWND hwnd)
{ {
RECT rect; RECT rect;
GetWindowRect(hwnd, if (GetWindowRect(hwnd,
&rect); &rect))
{
/* tools datum */ /* tools datum */
MoveWindow(FloatingToolbar[0].hSelf, MoveWindow(FloatingWindow[0].hSelf,
rect.left + 5, rect.left + 5,
rect.top + 5, rect.top + 5,
FloatingToolbar[0].Width, FloatingWindow[0].Width,
FloatingToolbar[0].Height, FloatingWindow[0].Height,
TRUE); TRUE);
/* colors datum */ /* colors datum */
MoveWindow(FloatingToolbar[1].hSelf, MoveWindow(FloatingWindow[1].hSelf,
rect.left + 5, rect.left + 5,
rect.bottom - FloatingToolbar[1].Height - 5, rect.bottom - FloatingWindow[1].Height - 5,
FloatingToolbar[1].Width, FloatingWindow[1].Width,
FloatingToolbar[1].Height, FloatingWindow[1].Height,
TRUE); TRUE);
/* history datum */ /* history datum */
MoveWindow(FloatingToolbar[2].hSelf, MoveWindow(FloatingWindow[2].hSelf,
rect.right - FloatingToolbar[2].Width - 5, rect.right - FloatingWindow[2].Width - 5,
rect.top + 5, rect.top + 5,
FloatingToolbar[2].Width, FloatingWindow[2].Width,
FloatingToolbar[2].Height, FloatingWindow[2].Height,
TRUE); TRUE);
} }
}
static VOID static VOID
MainWndCreateFloatToolbars(PMAIN_WND_INFO Info) MainWndCreateFloatWindows(PMAIN_WND_INFO Info)
{ {
RECT rect; RECT rect;
const TBBUTTON *Buttons = NULL; const TBBUTTON *Buttons = NULL;
UINT Res, NumButtons = 2; UINT Res, NumButtons = 2;
INT i = 0; INT i = 0;
GetWindowRect(Info->hMdiClient, if (! GetWindowRect(Info->hMdiClient,
&rect); &rect))
{
return;
}
/* tools datum */ /* tools datum */
FloatingToolbar[0].x = rect.left + 5; FloatingWindow[0].x = rect.left + 5;
FloatingToolbar[0].y = rect.top + 5; FloatingWindow[0].y = rect.top + 5;
/* colors datum */ /* colors datum */
FloatingToolbar[1].x = rect.left + 5; FloatingWindow[1].x = rect.left + 5;
FloatingToolbar[1].y = rect.bottom - FloatingToolbar[1].Height - 5; FloatingWindow[1].y = rect.bottom - FloatingWindow[1].Height - 5;
/* history datum */ /* history datum */
FloatingToolbar[2].x = rect.right - FloatingToolbar[2].Width - 5; FloatingWindow[2].x = rect.right - FloatingWindow[2].Width - 5;
FloatingToolbar[2].y = rect.top + 5; FloatingWindow[2].y = rect.top + 5;
for (Res = IDS_FLT_TOOLS; Res < IDS_FLT_TOOLS + NUM_FLT_TB; Res++, i++) for (Res = IDS_FLT_TOOLS; Res < IDS_FLT_TOOLS + NUM_FLT_WND; Res++, i++)
{ {
if (! AllocAndLoadString(&FloatingToolbar[i].lpName, if (! AllocAndLoadString(&FloatingWindow[i].lpName,
hInstance, hInstance,
Res)) Res))
{ {
FloatingToolbar[i].lpName = NULL; FloatingWindow[i].lpName = NULL;
} }
/* create the 'tools' toolbar */ /* create the 'tools' toolbar */
FloatingToolbar[i].hSelf = CreateWindowEx(WS_EX_TOOLWINDOW, FloatingWindow[i].hSelf = CreateWindowEx(WS_EX_TOOLWINDOW,
TEXT("ImageSoftFloatWndClass"), TEXT("ImageSoftFloatWndClass"),
FloatingToolbar[i].lpName, FloatingWindow[i].lpName,
WS_POPUPWINDOW | WS_DLGFRAME | WS_VISIBLE, WS_POPUPWINDOW | WS_DLGFRAME | WS_VISIBLE,
FloatingToolbar[i].x, FloatingWindow[i].x,
FloatingToolbar[i].y, FloatingWindow[i].y,
FloatingToolbar[i].Width, FloatingWindow[i].Width,
FloatingToolbar[i].Height, FloatingWindow[i].Height,
Info->hSelf, Info->hSelf,
NULL, NULL,
hInstance, hInstance,
@ -527,7 +551,7 @@ CreateToolbars(PMAIN_WND_INFO Info)
&MainWndDockBarCallbacks); &MainWndDockBarCallbacks);
} }
MainWndCreateFloatToolbars(Info); MainWndCreateFloatWindows(Info);
} }
static VOID CALLBACK static VOID CALLBACK
@ -707,6 +731,10 @@ MainWndCommand(PMAIN_WND_INFO Info,
break; break;
} }
case ID_BOLD:
MessageBox(NULL, _T("Bingo"), NULL, 0);
break;
case ID_OPEN: case ID_OPEN:
{ {
OPEN_IMAGE_EDIT_INFO OpenInfo; OPEN_IMAGE_EDIT_INFO OpenInfo;
@ -861,7 +889,7 @@ MainWndProc(HWND hwnd,
/* reposition the floating toolbars */ /* reposition the floating toolbars */
if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED)) if ((wParam == SIZE_MAXIMIZED) || (wParam == SIZE_RESTORED))
MainWndResetFloatingToolbars(Info->hMdiClient); MainWndResetFloatingWindows(Info->hMdiClient);
break; break;
} }
@ -875,6 +903,7 @@ MainWndProc(HWND hwnd,
break; break;
case WM_NCLBUTTONUP : case WM_NCLBUTTONUP :
bLBMouseDown = FALSE; bLBMouseDown = FALSE;
DefWindowProc(hwnd, DefWindowProc(hwnd,
uMsg, uMsg,
@ -886,7 +915,7 @@ MainWndProc(HWND hwnd,
{ {
/* if the main window is moved, move the toolbars too */ /* if the main window is moved, move the toolbars too */
if (bLBMouseDown) if (bLBMouseDown)
MainWndMoveFloatingToolbars(hwnd, &wndOldPos); MainWndMoveFloatingWindows(hwnd, &wndOldPos);
} }
break; break;

View file

@ -131,6 +131,7 @@ typedef struct _EDIT_WND_INFO
struct _EDIT_WND_INFO *Next; struct _EDIT_WND_INFO *Next;
POINT ScrollPos; POINT ScrollPos;
USHORT Zoom; USHORT Zoom;
DWORD Tool;
POPEN_IMAGE_EDIT_INFO OpenInfo; /* Only valid during initialization */ POPEN_IMAGE_EDIT_INFO OpenInfo; /* Only valid during initialization */
@ -332,7 +333,7 @@ BOOL DoOpenFile(HWND hwnd, LPTSTR lpFileName, LPTSTR lpName);
BOOL DoSaveFile(HWND hwnd); BOOL DoSaveFile(HWND hwnd);
/* floattoolbar.c */ /* floattoolbar.c */
typedef struct _FLT_TB typedef struct _FLT_WND
{ {
HWND hSelf; HWND hSelf;
LPTSTR lpName; LPTSTR lpName;
@ -340,10 +341,11 @@ typedef struct _FLT_TB
INT y; INT y;
INT Width; INT Width;
INT Height; INT Height;
} FLT_TB, *PFLT_TB; BOOL bOpaque;
} FLT_WND, *PFLT_WND;
BOOL InitFloatWndClass(VOID); BOOL InitFloatWndClass(VOID);
VOID UninitFloatWndImpl(VOID); VOID UninitFloatWndImpl(VOID);
BOOL ShowHideToolbar(HWND hwnd); BOOL ShowHideWindow(HWND hwnd);
#endif /* __IMAGESOFT_PRECOMP_H */ #endif /* __IMAGESOFT_PRECOMP_H */

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 B

View file

@ -29,7 +29,12 @@
#define ID_EDITCOLOURS 2017 #define ID_EDITCOLOURS 2017
#define ID_TOOLS 2018 #define ID_TOOLS 2018
#define ID_STATUSBAR 2019 #define ID_STATUSBAR 2019
#define ID_BOLD 2030
#define ID_ITALIC 2031
#define ID_ULINE 2032
#define ID_TXTLEFT 2033
#define ID_TXTCENTER 2034
#define ID_TXTRIGHT 2035
#define ID_REFRESH 3000 #define ID_REFRESH 3000
#define ID_HELP 3001 #define ID_HELP 3001
@ -77,6 +82,13 @@
#define TBICON_HELP 8 #define TBICON_HELP 8
#define TBICON_EXIT 9 #define TBICON_EXIT 9
#define TBICON_BOLD 10
#define TBICON_ITALIC 11
#define TBICON_ULINE 12
#define TBICON_TXTLEFT 13
#define TBICON_TXTCENTER 14
#define TBICON_TXTRIGHT 15
/* about box info */ /* about box info */
#define IDD_ABOUTBOX 200 #define IDD_ABOUTBOX 200
#define IDC_LICENSE_EDIT 201 #define IDC_LICENSE_EDIT 201
@ -87,7 +99,8 @@
#define IDS_READY 104 #define IDS_READY 104
#define IDS_TOOLBAR_STANDARD 201 #define IDS_TOOLBAR_STANDARD 201
#define IDS_TOOLBAR_TEST 202 #define IDS_TOOLBAR_TEST 202
#define IDS_IMAGE_NAME 203 #define IDS_TOOLBAR_TEXT 203
#define IDS_IMAGE_NAME 210
/* menu hints */ /* menu hints */
#define IDS_HINT_EXIT 20001 #define IDS_HINT_EXIT 20001
@ -127,8 +140,6 @@
#define IDS_UNIT_KB 4110 #define IDS_UNIT_KB 4110
/* toolbar buttons resources /* toolbar buttons resources
* these must be numbered consecutively * these must be numbered consecutively
* see loop in InitImageList */ * see loop in InitImageList */
@ -142,6 +153,13 @@
#define IDB_MAINPASTEICON 10007 #define IDB_MAINPASTEICON 10007
#define IDB_MAINUNDOICON 10008 #define IDB_MAINUNDOICON 10008
#define IDB_MAINREDOICON 10009 #define IDB_MAINREDOICON 10009
#define IDB_TEXTBOLD 10020
#define IDB_TEXTITALIC 10021
#define IDB_TEXTULINE 10022
#define IDB_TEXTLEFT 10023
#define IDB_TEXTCENTER 10024
#define IDB_TEXTRIGHT 10025
/* toolbar buttons */ /* toolbar buttons */
#define TBICON_NEW 0 #define TBICON_NEW 0