Commit 3e00dec8 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

- Add the toolbar to the viewer window.

- Load the toolbar button text from the resource file.
parent 760ff433
Makefile Makefile
hhctrl.ocx.dbg.c hhctrl.ocx.dbg.c
version.res hhctrl.res
/*
* HTML Help resources
* English Language Support
*
* Copyright 2005 James Hawkins
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
STRINGTABLE
BEGIN
IDTB_EXPAND "Show"
IDTB_CONTRACT "Hide"
IDTB_STOP "Stop"
IDTB_REFRESH "Refresh"
IDTB_BACK "Back"
IDTB_HOME "Home"
IDTB_SYNC "Sync"
IDTB_PRINT "Print"
IDTB_OPTIONS "Options"
IDTB_FORWARD "Forward"
IDTB_NOTES "IDTB_NOTES"
IDTB_BROWSE_FWD "IDTB_BROWSE_FWD"
IDTB_BROWSE_BACK "IDT_BROWSE_BACK"
IDTB_CONTENTS "IDTB_CONTENTS"
IDTB_INDEX "IDTB_INDEX"
IDTB_SEARCH "IDTB_SEARCH"
IDTB_HISTORY "IDTB_HISTORY"
IDTB_FAVORITES "IDTB_FAVORITES"
IDTB_JUMP1 "Jump1"
IDTB_JUMP2 "Jump2"
IDTB_CUSTOMIZE "Customize"
IDTB_ZOOM "Zoom"
IDTB_TOC_NEXT "IDTB_TOC_NEXT"
IDTB_TOC_PREV "IDTB_TOC_PREV"
END
...@@ -11,7 +11,7 @@ C_SRCS = \ ...@@ -11,7 +11,7 @@ C_SRCS = \
main.c \ main.c \
regsvr.c regsvr.c
RC_SRCS = version.rc RC_SRCS = hhctrl.rc
@MAKE_DLL_RULES@ @MAKE_DLL_RULES@
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "commctrl.h" #include "commctrl.h"
#include "htmlhelp.h" #include "htmlhelp.h"
#include "ole2.h" #include "ole2.h"
#include "wine/unicode.h"
/* Window type defaults */ /* Window type defaults */
...@@ -41,9 +42,12 @@ typedef struct tagHHInfo ...@@ -41,9 +42,12 @@ typedef struct tagHHInfo
HH_WINTYPEW *pHHWinType; HH_WINTYPEW *pHHWinType;
HINSTANCE hInstance; HINSTANCE hInstance;
LPCWSTR szCmdLine; LPCWSTR szCmdLine;
DWORD dwNumTBButtons;
HFONT hFont; HFONT hFont;
} HHInfo; } HHInfo;
extern HINSTANCE hhctrl_hinstance;
static LPWSTR HH_ANSIToUnicode(LPCSTR ansi) static LPWSTR HH_ANSIToUnicode(LPCSTR ansi)
{ {
LPWSTR unicode; LPWSTR unicode;
...@@ -56,10 +60,133 @@ static LPWSTR HH_ANSIToUnicode(LPCSTR ansi) ...@@ -56,10 +60,133 @@ static LPWSTR HH_ANSIToUnicode(LPCSTR ansi)
return unicode; return unicode;
} }
/* Loads a string from the resource file */
static LPWSTR HH_LoadString(DWORD dwID)
{
LPWSTR string = NULL;
int iSize;
iSize = LoadStringW(hhctrl_hinstance, dwID, NULL, 0);
iSize += 2; /* some strings (tab text) needs double-null termination */
string = HeapAlloc(GetProcessHeap(), 0, iSize * sizeof(WCHAR));
LoadStringW(hhctrl_hinstance, dwID, string, iSize);
return string;
}
/* Toolbar */ /* Toolbar */
#define ICON_SIZE 20
static void TB_AddButton(TBBUTTON *pButtons, DWORD dwIndex, DWORD dwID)
{
/* FIXME: Load the correct button bitmaps */
pButtons[dwIndex].iBitmap = STD_PRINT;
pButtons[dwIndex].idCommand = dwID;
pButtons[dwIndex].fsState = TBSTATE_ENABLED;
pButtons[dwIndex].fsStyle = BTNS_BUTTON;
pButtons[dwIndex].dwData = 0;
pButtons[dwIndex].iString = 0;
}
static void TB_AddButtonsFromFlags(TBBUTTON *pButtons, DWORD dwButtonFlags, LPDWORD pdwNumButtons)
{
*pdwNumButtons = 0;
if (dwButtonFlags & HHWIN_BUTTON_EXPAND)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_EXPAND);
if (dwButtonFlags & HHWIN_BUTTON_BACK)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_BACK);
if (dwButtonFlags & HHWIN_BUTTON_FORWARD)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_FORWARD);
if (dwButtonFlags & HHWIN_BUTTON_STOP)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_STOP);
if (dwButtonFlags & HHWIN_BUTTON_REFRESH)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_REFRESH);
if (dwButtonFlags & HHWIN_BUTTON_HOME)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_HOME);
if (dwButtonFlags & HHWIN_BUTTON_SYNC)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_SYNC);
if (dwButtonFlags & HHWIN_BUTTON_OPTIONS)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_OPTIONS);
if (dwButtonFlags & HHWIN_BUTTON_PRINT)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_PRINT);
if (dwButtonFlags & HHWIN_BUTTON_JUMP1)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_JUMP1);
if (dwButtonFlags & HHWIN_BUTTON_JUMP2)
TB_AddButton(pButtons,(*pdwNumButtons)++, IDTB_JUMP2);
if (dwButtonFlags & HHWIN_BUTTON_ZOOM)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_ZOOM);
if (dwButtonFlags & HHWIN_BUTTON_TOC_NEXT)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_NEXT);
if (dwButtonFlags & HHWIN_BUTTON_TOC_PREV)
TB_AddButton(pButtons, (*pdwNumButtons)++, IDTB_TOC_PREV);
}
static BOOL HH_AddToolbar(HHInfo *pHHInfo) static BOOL HH_AddToolbar(HHInfo *pHHInfo)
{ {
HWND hToolbar;
HWND hwndParent = pHHInfo->pHHWinType->hwndHelp;
DWORD toolbarFlags = pHHInfo->pHHWinType->fsToolBarFlags;
TBBUTTON buttons[IDTB_TOC_PREV - IDTB_EXPAND];
TBADDBITMAP tbAB;
DWORD dwStyles, dwExStyles;
DWORD dwNumButtons, dwIndex;
/* FIXME: Remove the following line once we read the CHM file */
toolbarFlags = HHWIN_BUTTON_EXPAND | HHWIN_BUTTON_BACK | HHWIN_BUTTON_STOP |
HHWIN_BUTTON_REFRESH | HHWIN_BUTTON_HOME | HHWIN_BUTTON_PRINT;
TB_AddButtonsFromFlags(buttons, toolbarFlags, &dwNumButtons);
pHHInfo->dwNumTBButtons = dwNumButtons;
dwStyles = WS_CHILDWINDOW | WS_VISIBLE | TBSTYLE_FLAT |
TBSTYLE_WRAPABLE | TBSTYLE_TOOLTIPS | CCS_NODIVIDER;
dwExStyles = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR;
hToolbar = CreateWindowExW(dwExStyles, TOOLBARCLASSNAMEW, NULL, dwStyles,
0, 0, 0, 0, hwndParent, NULL,
pHHInfo->hInstance, NULL);
if (!hToolbar)
return FALSE;
SendMessageW(hToolbar, TB_SETBITMAPSIZE, 0, MAKELONG(ICON_SIZE, ICON_SIZE));
SendMessageW(hToolbar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
SendMessageW(hToolbar, WM_SETFONT, (WPARAM)pHHInfo->hFont, TRUE);
/* FIXME: Load correct icons for all buttons */
tbAB.hInst = HINST_COMMCTRL;
tbAB.nID = IDB_STD_LARGE_COLOR;
SendMessageW(hToolbar, TB_ADDBITMAP, 0, (LPARAM)&tbAB);
for (dwIndex = 0; dwIndex < dwNumButtons; dwIndex++)
{
LPWSTR szBuf = HH_LoadString(buttons[dwIndex].idCommand);
DWORD dwLen = strlenW(szBuf);
szBuf[dwLen + 2] = 0; /* Double-null terminate */
buttons[dwIndex].iString = (DWORD)SendMessageW(hToolbar, TB_ADDSTRINGW, 0, (LPARAM)szBuf);
HeapFree(GetProcessHeap(), 0, szBuf);
}
SendMessageW(hToolbar, TB_ADDBUTTONSW, dwNumButtons, (LPARAM)&buttons);
SendMessageW(hToolbar, TB_AUTOSIZE, 0, 0);
ShowWindow(hToolbar, SW_SHOW);
pHHInfo->pHHWinType->hwndToolBar = hToolbar;
return TRUE; return TRUE;
} }
......
/*
* HTML Help resources
*
* Copyright 2005 James Hawkins
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "htmlhelp.h"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#include "version.rc"
#include "En.rc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment