- allow container windows on the docking toolbars

- hide comboboxes if toolbar is vertical
- patch from Thomas

svn path=/trunk/; revision=21515
This commit is contained in:
Ged Murphy 2006-04-07 23:21:12 +00:00
parent 2e69e8f9d1
commit d574bdb7c7
11 changed files with 348 additions and 58 deletions

View file

@ -1,39 +0,0 @@
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
TBBUTTON StdButtons[] = {
{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},
};
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

@ -5,9 +5,9 @@ static HWND hImageType, hUnitType, hHeightUnit, hWidthUnit, hResUnit;
UINT ConvertValue(HWND hDlg, UINT EdBoxChanged, UINT LastUnitSel)
{
LONG Resolution = GetDlgItemInt(hDlg, IDC_RES_EDIT, NULL, FALSE);
FLOAT Width = GetDlgItemInt(hDlg, IDC_WIDTH_EDIT, NULL, FALSE);
FLOAT Height = GetDlgItemInt(hDlg, IDC_HEIGHT_EDIT, NULL, FALSE);
USHORT CurUnit = SendMessage(hUnitType, CB_GETCURSEL, 0, 0);
FLOAT Width = (FLOAT)GetDlgItemInt(hDlg, IDC_WIDTH_EDIT, NULL, FALSE);
FLOAT Height = (FLOAT)GetDlgItemInt(hDlg, IDC_HEIGHT_EDIT, NULL, FALSE);
USHORT CurUnit = (USHORT)SendMessage(hUnitType, CB_GETCURSEL, 0, 0);
/* if the user typed in the resolution box */
if ((EdBoxChanged == IDC_RES_EDIT) && (CurUnit != PIXELS))

View file

@ -7,7 +7,6 @@
<define name="__USE_W32API" />
<define name="_WIN32_IE">0x0600</define>
<define name="_WIN32_WINNT">0x0501</define>
<library>ntdll</library>
<library>kernel32</library>
<library>gdi32</library>
<library>user32</library>

View file

@ -2,15 +2,15 @@
#include <commctrl.h>
#include "resource.h"
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS image editor\0"
#define REACTOS_STR_INTERNAL_NAME "imagesoft\0"
#define REACTOS_STR_ORIGINAL_FILENAME "imagesoft.exe\0"
#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>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
1 24 DISCARDABLE "manifest.xml"
STRINGTABLE DISCARDABLE
BEGIN
IDS_APPNAME "ImageSoft"

View file

@ -1,5 +1,4 @@
#include <precomp.h>
#include "buttons.h"
static const TCHAR szMainWndClass[] = TEXT("ImageSoftWndClass");
@ -7,6 +6,50 @@ static const TCHAR szMainWndClass[] = TEXT("ImageSoftWndClass");
#define ID_MDI_WINDOWMENU 5
#define NUM_FLT_WND 3
/* toolbar buttons */
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},
};
TBBUTTON TextButtons[] = {
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{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 */
};
/* menu hints */
static const MENU_HINT MainMenuHintTable[] = {
/* File Menu */
@ -111,7 +154,7 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
{
const TBBUTTON *Buttons = NULL;
UINT NumButtons = 0;
UINT StartImageRes;
UINT StartImageRes = 0;
HWND hWndClient = NULL;
UNREFERENCED_PARAMETER(Context);
@ -207,6 +250,40 @@ MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
}
}
switch (Dockbar->BarId)
{
case ID_TOOLBAR_TEXT:
{
HWND hWndCombo;
/* drop combo box into container window */
hWndCombo = CreateWindowEx(0,
WC_COMBOBOX,
NULL,
WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
0, 0, 120, 25,
hParent,
NULL,
hInstance,
NULL);
if (hWndCombo != NULL)
{
SetParent(hWndCombo,
hWndClient);
if (!ToolbarInsertSpaceForControl(hWndClient,
hWndCombo,
0,
ID_TXTFONTNAME,
TRUE))
{
DestroyWindow(hWndCombo);
}
}
break;
}
}
if (hWndClient != NULL)
{
*hwnd = hWndClient;
@ -277,6 +354,15 @@ MainWndToolbarInsertBand(struct _TOOLBAR_DOCKS *TbDocks,
return TRUE;
}
static VOID
TbCustomControlChange(HWND hWndToolbar,
HWND hWndControl,
BOOL Vert)
{
/* the toolbar changed from horizontal to vertical or vice versa... */
return;
}
static VOID CALLBACK
MainWndToolbarDockBand(struct _TOOLBAR_DOCKS *TbDocks,
const DOCKBAR *Dockbar,
@ -317,6 +403,9 @@ MainWndToolbarDockBand(struct _TOOLBAR_DOCKS *TbDocks,
0,
(LPARAM)dwStyle);
ToolbarUpdateControlSpaces(rbi->hwndChild,
TbCustomControlChange);
if (SendMessage(rbi->hwndChild,
TB_GETMAXSIZE,
0,
@ -630,6 +719,7 @@ static VOID
InitMainWnd(PMAIN_WND_INFO Info)
{
CLIENTCREATESTRUCT ccs;
INT statwidths[] = {110, -1};
/* FIXME - create controls and initialize the application */
@ -647,6 +737,12 @@ InitMainWnd(PMAIN_WND_INFO Info)
hInstance,
NULL);
if (Info->hStatus != NULL)
SendMessage(Info->hStatus,
SB_SETPARTS,
sizeof(statwidths)/sizeof(int),
(LPARAM)statwidths);
/* create the MDI client window */
ccs.hWindowMenu = GetSubMenu(GetMenu(Info->hSelf),
ID_MDI_WINDOWMENU);
@ -921,11 +1017,33 @@ MainWndProc(HWND hwnd,
case WM_NOTIFY:
{
UINT BarId;
LPNMHDR pnmhdr = (LPNMHDR)lParam;
if (!TbdHandleNotifications(&Info->ToolDocks,
(LPNMHDR)lParam,
pnmhdr,
&Ret))
{
/* FIXME - handle other notifications */
if (TbdDockBarIdFromClientWindow(&Info->ToolDocks,
pnmhdr->hwndFrom,
&BarId))
{
switch (BarId)
{
case ID_TOOLBAR_TEXT:
switch (pnmhdr->code)
{
case TBN_DELETINGBUTTON:
{
LPNMTOOLBAR lpnmtb = (LPNMTOOLBAR)lParam;
ToolbarDeleteControlSpace(pnmhdr->hwndFrom,
&lpnmtb->tbButton);
break;
}
}
break;
}
}
}
break;
}

View file

@ -47,7 +47,7 @@ AllocAndLoadString(OUT LPTSTR *lpTarget,
uID);
if (ln++ > 0)
{
(*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
(*lpTarget) = (LPTSTR)LocalAlloc(LMEM_FIXED,
ln * sizeof(TCHAR));
if ((*lpTarget) != NULL)
{
@ -207,3 +207,169 @@ VOID MessageBoxInt(INT num)
{
MessageBox(NULL, _itot(num, NULL, 10), NULL, 0);
}
/*
* Toolbar custom control routines
*/
typedef struct _TBCUSTCTL
{
HWND hWndControl;
INT iCommand;
BOOL HideVertical : 1;
BOOL IsVertical : 1;
} TBCUSTCTL, *PTBCUSTCTL;
BOOL
ToolbarDeleteControlSpace(HWND hWndToolbar,
const TBBUTTON *ptbButton)
{
if ((ptbButton->fsStyle & TBSTYLE_SEP) &&
ptbButton->dwData != 0)
{
PTBCUSTCTL cctl = (PTBCUSTCTL)ptbButton->dwData;
DestroyWindow(cctl->hWndControl);
HeapFree(ProcessHeap,
0,
cctl);
return TRUE;
}
return FALSE;
}
VOID
ToolbarUpdateControlSpaces(HWND hWndToolbar,
ToolbarChangeControlCallback ChangeCallback)
{
BOOL Vert;
DWORD nButtons, i;
TBBUTTON tbtn;
Vert = ((SendMessage(hWndToolbar,
TB_GETSTYLE,
0,
0) & CCS_VERT) != 0);
nButtons = SendMessage(hWndToolbar,
TB_BUTTONCOUNT,
0,
0);
for (i = 0;
i != nButtons;
i++)
{
if (SendMessage(hWndToolbar,
TB_GETBUTTON,
(WPARAM)i,
(LPARAM)&tbtn))
{
if ((tbtn.fsStyle & TBSTYLE_SEP) && tbtn.dwData != 0)
{
PTBCUSTCTL cctl = (PTBCUSTCTL)tbtn.dwData;
cctl->IsVertical = Vert;
if (cctl->HideVertical)
{
ShowWindow(cctl->hWndControl,
(Vert ? SW_HIDE : SW_SHOW));
goto ShowHideSep;
}
else if (cctl->IsVertical != Vert)
{
ChangeCallback(hWndToolbar,
cctl->hWndControl,
Vert);
ShowHideSep:
/* show/hide the separator */
SendMessage(hWndToolbar,
TB_HIDEBUTTON,
(WPARAM)cctl->iCommand,
(LPARAM)Vert && cctl->HideVertical);
}
}
}
}
}
BOOL
ToolbarInsertSpaceForControl(HWND hWndToolbar,
HWND hWndControl,
INT Index,
INT iCmd,
BOOL HideVertical)
{
PTBCUSTCTL cctl;
RECT rcControl, rcItem;
cctl = HeapAlloc(ProcessHeap,
0,
sizeof(TBCUSTCTL));
if (cctl == NULL)
return FALSE;
cctl->HideVertical = HideVertical;
cctl->hWndControl = hWndControl;
cctl->iCommand = iCmd;
if (GetWindowRect(hWndControl,
&rcControl))
{
TBBUTTON tbtn = {0};
tbtn.iBitmap = rcControl.right - rcControl.left;
tbtn.idCommand = iCmd;
tbtn.fsStyle = TBSTYLE_SEP;
tbtn.dwData = (DWORD_PTR)cctl;
if (SendMessage(hWndToolbar,
TB_GETSTYLE,
0,
0) & CCS_VERT)
{
if (HideVertical)
tbtn.fsState |= TBSTATE_HIDDEN;
cctl->IsVertical = TRUE;
}
else
cctl->IsVertical = FALSE;
if (SendMessage(hWndToolbar,
TB_INSERTBUTTON,
(WPARAM)Index,
(LPARAM)&tbtn))
{
if (SendMessage(hWndToolbar,
TB_GETITEMRECT,
(WPARAM)Index,
(LPARAM)&rcItem))
{
SetWindowPos(hWndControl,
NULL,
rcItem.left,
rcItem.top,
rcItem.right - rcItem.left,
rcItem.bottom - rcItem.top,
SWP_NOZORDER);
ShowWindow(hWndControl,
SW_SHOW);
return TRUE;
}
else if (tbtn.fsState & TBSTATE_HIDDEN)
{
ShowWindow(hWndControl,
SW_HIDE);
}
}
}
return FALSE;
}

View file

@ -37,7 +37,7 @@ DoOpenFile(HWND hwnd,
_T("TAG Image File Format (*tif)\0*.tif\0") \
_T("Portable Network Graphics (*png)\0*.png\0\0");*/
static TCHAR Filter[] = _T("Windows Bitmap (*bmp)\0*.bmp\0");
static TCHAR Filter[] = _T("Windows Bitmap (*.bmp)\0*.bmp\0");
ofn.lpstrFilter = Filter;
ofn.lpstrFile = szFileName;

View file

@ -19,7 +19,10 @@
#ifndef RBN_CHEVRONPUSHED
#define RBN_CHEVRONPUSHED (RBN_FIRST - 10)
#endif
ULONG DbgPrint(PCH Format,...);
#ifdef _MSC_VER
#pragma warning(disable : 4100)
#endif
#define MAX_KEY_LENGTH 256
#define NUM_MAINTB_IMAGES 10
@ -152,8 +155,8 @@ VOID SetImageEditorEnvironment(PEDIT_WND_INFO Info,
BOOL InitImageEditWindowImpl(VOID);
VOID UninitImageEditWindowImpl(VOID);
/* tooldock.c */
/* tooldock.c */
typedef enum
{
TOP_DOCK = 0,
@ -251,6 +254,9 @@ BOOL TbdAddToolbar(PTOOLBAR_DOCKS TbDocks,
const DOCKBAR *Dockbar,
PVOID Context,
const DOCKBAR_ITEM_CALLBACKS *DockbarCallbacks);
BOOL TbdDockBarIdFromClientWindow(PTOOLBAR_DOCKS TbDocks,
HWND hWndClient,
UINT *Id);
BOOL TbdHandleNotifications(PTOOLBAR_DOCKS TbDocks,
LPNMHDR pnmh,
LRESULT *Result);
@ -334,6 +340,21 @@ VOID GetError(DWORD err);
VOID MessageBoxInt(INT num);
BOOL ToolbarDeleteControlSpace(HWND hWndToolbar,
const TBBUTTON *ptbButton);
typedef VOID (*ToolbarChangeControlCallback)(HWND hWndToolbar,
HWND hWndControl,
BOOL Vert);
VOID ToolbarUpdateControlSpaces(HWND hWndToolbar,
ToolbarChangeControlCallback ChangeCallback);
BOOL ToolbarInsertSpaceForControl(HWND hWndToolbar,
HWND hWndControl,
INT Index,
INT iCmd,
BOOL HideVertical);
/* opensave.c */
VOID FileInitialize(HWND hwnd);
BOOL DoOpenFile(HWND hwnd, LPTSTR lpFileName, LPTSTR lpName);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 824 B

After

Width:  |  Height:  |  Size: 822 B

View file

@ -35,6 +35,7 @@
#define ID_TXTLEFT 2033
#define ID_TXTCENTER 2034
#define ID_TXTRIGHT 2035
#define ID_TXTFONTNAME 2036
#define ID_REFRESH 3000
#define ID_HELP 3001

View file

@ -263,6 +263,30 @@ TbnRebarEndDrag(PTOOLBAR_DOCKS TbDocks,
}
}
BOOL
TbdDockBarIdFromClientWindow(PTOOLBAR_DOCKS TbDocks,
HWND hWndClient,
UINT *Id)
{
PDOCKBAR_ITEM Item;
BOOL Ret = FALSE;
Item = TbDocks->Items;
while (Item != NULL)
{
if (Item->hWndClient == hWndClient)
{
*Id = Item->DockBar.BarId;
Ret = TRUE;
break;
}
Item = Item->Next;
}
return Ret;
}
BOOL
TbdHandleNotifications(PTOOLBAR_DOCKS TbDocks,
LPNMHDR pnmh,
@ -976,13 +1000,13 @@ TbdHandleActivation(PTOOLBAR_DOCKS TbDocks,
BOOL KeepActive = *(BOOL*)wParam;
HWND hWndActivate = *(HWND*)lParam;
PDOCKBAR_ITEM Item;
DbgPrint("-- 0x%p --\n", hWnd);
Item = TbDocks->Items;
while (Item != NULL)
{
if (Item->hWndTool != NULL &&
Item->hWndTool == hWndActivate)
{DbgPrint("Activate toolbars (0x%p)\n", hWndActivate);
{
KeepActive = TRUE;
SynchronizeSiblings = FALSE;
break;
@ -1000,7 +1024,7 @@ DbgPrint("-- 0x%p --\n", hWnd);
if (Item->hWndTool != NULL &&
Item->hWndTool != hWnd &&
Item->hWndTool != hWndActivate)
{DbgPrint("WM_NCACTIVE %p (wnd %p)\n", KeepActive, Item->hWndTool);
{
SendMessage(Item->hWndTool,
WM_NCACTIVATE,
(WPARAM)KeepActive,