1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
|
/*******************************************************************************
* pvmenu.cpp
*
* This module implements menu-related routines for the Windows build of POV.
*
* Author: Christopher J. Cason.
*
* ---------------------------------------------------------------------------
* Persistence of Vision Ray Tracer ('POV-Ray') version 3.7.
* Copyright 1991-2013 Persistence of Vision Raytracer Pty. Ltd.
*
* POV-Ray is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* POV-Ray 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------------
* POV-Ray is based on the popular DKB raytracer version 2.12.
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/windows/pvmenu.cpp $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
*******************************************************************************/
// REMOVAL OF NON-EXPERT MENUS (August 1998) ... the 'non-expert menus' option
// was removed. This leaves some of this code redundant, but here it is anyhow ...
#define POVWIN_FILE
#define _WIN32_IE COMMONCTRL_VERSION
#include <windows.h>
#include <commctrl.h>
#include <setjmp.h>
#include <string.h>
#include "pvengine.h"
#include "resource.h"
#include "pvedit.h"
#include "pvdisplay.h"
#ifdef RTR_SUPPORT
#include "rtrsupport.h"
#endif
// this must be the last file included
#include "syspovdebug.h"
namespace povwin
{
bool MenuBarDraw = false ;
char WindowList[MAX_EDITORS + 1][_MAX_PATH];
HMENU hMainMenu ;
HMENU hMenuBar ;
HMENU hPopupMenus ;
HMENU hFileMenu ;
HMENU hEditMenu ;
HMENU hRenderMenu ;
HMENU hOptionsMenu ;
HMENU hToolsMenu ;
HMENU hPluginsMenu ;
HMENU hHelpMenu ;
HMENU hOldRenderwinMenu ;
HMENU hNewRenderwinMenu ;
HMENU hVidcapMenu ;
HACCEL hAccelerators ;
extern HWND main_window ;
extern HWND toolbar_window ;
extern bool RenderwinIsChild ;
extern bool preserve_bitmap ;
extern bool rendering ;
extern bool render_auto_close ;
extern bool IsVista ;
extern unsigned renderwin_8bits ;
bool PVEnableMenuItem (UINT idItem, UINT state)
{
EnableMenuItem (hPopupMenus, idItem, state) ;
EnableMenuItem (hMenuBar, idItem, state) ;
SendMessage (toolbar_window, TB_ENABLEBUTTON, idItem, MAKELONG (state == MF_ENABLED, 0)) ;
if (idItem == CM_RENDERCLOSE)
{
SendMessage (toolbar_window, TB_HIDEBUTTON, CM_RENDERSHOW, MAKELONG (state == MF_ENABLED, 0)) ;
SendMessage (toolbar_window, TB_HIDEBUTTON, CM_RENDERCLOSE, MAKELONG (state != MF_ENABLED, 0)) ;
}
return (true) ;
}
bool PVCheckMenuItem (UINT idItem, UINT state)
{
CheckMenuItem (hPopupMenus, idItem, state) ;
CheckMenuItem (hMenuBar, idItem, state) ;
return (true) ;
}
bool PVCheckMenuRadioItem (UINT idFirst, UINT idLast, UINT idItem)
{
CheckMenuRadioItem (hPopupMenus, idFirst, idLast, idItem, MF_BYCOMMAND) ;
CheckMenuRadioItem (hMenuBar, idFirst, idLast, idItem, MF_BYCOMMAND) ;
return (true) ;
}
bool PVModifyMenu (UINT idItem, UINT flags, UINT idNewItem, LPCSTR lpNewItem)
{
ModifyMenu (hPopupMenus, idItem, flags, idNewItem, lpNewItem) ;
ModifyMenu (hMenuBar, idItem, flags, idNewItem, lpNewItem) ;
MenuBarDraw = true ;
return (true) ;
}
bool PVDeleteMenuItem (UINT idItem)
{
DeleteMenu (hPopupMenus, idItem, MF_BYCOMMAND) ;
DeleteMenu (hMenuBar, idItem, MF_BYCOMMAND) ;
return (true) ;
}
int find_menuitem (HMENU hMenu, LPCSTR title)
{
int max = GetMenuItemCount (hMenu) ;
char str [256] ;
if (title[0] == '\0')
return (-1);
for (int i = 0 ; i < 64 ; i++)
if (GetMenuString (hMenu, i, str, sizeof (str) - 1, MF_BYPOSITION) > 0)
if (strcmp (title, str) == 0)
return (i) ;
return (-1) ;
}
void init_menus (void)
{
hPopupMenus = LoadMenu (hInstance, MAKEINTRESOURCE (POPUP_MENUS32)) ;
hAccelerators = LoadAccelerators (hInstance, MAKEINTRESOURCE (PVENGINE_MENU)) ;
hMenuBar = LoadMenu (hInstance, MAKEINTRESOURCE (PVENGINE_MENU32)) ;
hFileMenu = GetSubMenu (hMenuBar, 0) ;
hEditMenu = GetSubMenu (hMenuBar, 1) ;
hRenderMenu = GetSubMenu (hMenuBar, 2) ;
hOptionsMenu = GetSubMenu (hMenuBar, 3) ;
hToolsMenu = GetSubMenu (hMenuBar, 4) ;
hHelpMenu = GetSubMenu (hMenuBar, 5) ;
hOldRenderwinMenu = GetSubMenu (hPopupMenus, 2) ;
hNewRenderwinMenu = GetSubMenu (hPopupMenus, 3) ;
int n = find_menuitem(hOptionsMenu, "&Other Settings") ;
assert(n != -1) ;
hVidcapMenu = GetSubMenu(GetSubMenu(hOptionsMenu, n), 0) ;
n = find_menuitem(hOptionsMenu, "GU&I-Extensions") ;
assert(n != -1) ;
hPluginsMenu = GetSubMenu(hOptionsMenu, n);
if (!IsVista)
{
RemoveMenu (hRenderMenu, CM_RENDERPRIORITY_BACKGROUND, MF_BYCOMMAND);
RemoveMenu (hPopupMenus, CM_RENDERPRIORITY_BACKGROUND, MF_BYCOMMAND);
}
#if POV_RAY_IS_OFFICIAL != 1
n = find_menuitem(hOptionsMenu, "&Update Checks") ;
assert(n != -1) ;
RemoveMenu (hOptionsMenu, n, MF_BYPOSITION);
RemoveMenu (hHelpMenu, CM_CHECKUPDATENOW, MF_BYCOMMAND);
#endif
}
void set_newuser_menu (HMENU hMenu, UINT ID, bool hide, bool separator)
{
if (GetMenuItemID (hMenu, 0) != ID)
{
if (hide)
return ;
if (separator)
InsertMenu (hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, NULL) ;
InsertMenu (hMenu, 0, MF_BYPOSITION, ID, "&Help On This Menu") ;
}
else
{
if (!hide)
return ;
DeleteMenu (hMenu, 0, MF_BYPOSITION) ;
if (separator)
DeleteMenu (hMenu, 0, MF_BYPOSITION) ;
}
}
void set_newuser_menus (bool hide)
{
set_newuser_menu (hFileMenu, CM_FILEMENUHELP, hide, true) ;
set_newuser_menu (hEditMenu, CM_EDITMENUHELP, hide, true) ;
set_newuser_menu (hRenderMenu, CM_RENDERMENUHELP, hide, true) ;
set_newuser_menu (hOptionsMenu, CM_OPTIONSMENUHELP, hide, true) ;
set_newuser_menu (hToolsMenu, CM_TOOLSMENUHELP, hide, false) ;
set_newuser_menu (hToolsMenu, CM_WINDOWMENUHELP, hide, true) ;
set_newuser_menu (GetSubMenu (hPopupMenus, 0), CM_MESSAGEWINMENUHELP, hide, true) ;
set_newuser_menu (GetSubMenu (hPopupMenus, 1), CM_RENDERWINMENUHELP, hide, true) ;
EditPassOnMessage (NULL, HIDE_NEWUSER_HELP_MESSAGE, hide, 0, NULL) ;
}
void clear_menu (HMENU hMenu)
{
while (RemoveMenu (hMenu, 0, MF_BYPOSITION)) ;
}
void setup_menus (bool have_editor)
{
if (have_editor)
AppendMenu (hOptionsMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetOptionsMenu), "&Editor Window") ;
#ifdef RTR_SUPPORT
std::vector<std::string> vidSources;
size_t numSources = GetVideoSourceNames(vidSources);
if (numSources > 0)
{
DeleteMenu (hVidcapMenu, 0, MF_BYPOSITION) ;
if (numSources > CM_LASTVIDEOSOURCE - CM_FIRSTVIDEOSOURCE + 1)
numSources = CM_LASTVIDEOSOURCE - CM_FIRSTVIDEOSOURCE + 1 ;
for (int i = 0; i < numSources; i++)
InsertMenu (hVidcapMenu, -1, MF_BYPOSITION, CM_FIRSTVIDEOSOURCE + i, vidSources[i].c_str()) ;
CheckMenuRadioItem(hVidcapMenu, CM_FIRSTVIDEOSOURCE, CM_LASTVIDEOSOURCE, CM_FIRSTVIDEOSOURCE, MF_BYCOMMAND);
int n = find_menuitem (hVidcapMenu, GetVideoSourceName().c_str());
if (n != -1)
CheckMenuRadioItem(hVidcapMenu, CM_FIRSTVIDEOSOURCE, CM_LASTVIDEOSOURCE, CM_FIRSTVIDEOSOURCE + n, MF_BYCOMMAND);
else
SetVideoSourceName(vidSources[0].c_str());
}
#endif
DrawMenuBar (main_window) ;
}
// build the menu displayed when the message window is selected
void build_main_menu (HMENU hMenu, bool have_editor)
{
clear_menu (hMenu) ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) (have_editor ? EditGetMenu (GetFileMenu) : hFileMenu), "&File") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hEditMenu, "&Edit") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hRenderMenu, "&Render") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hOptionsMenu, "&Options") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hToolsMenu, "&Tools") ;
if (EditGetMenu (GetWindowMenu) != NULL)
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetWindowMenu), "&Window") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hHelpMenu, "&Help") ;
DrawMenuBar (main_window) ;
}
// build the menu displayed when an editor window is selected
void build_editor_menu (HMENU hMenu)
{
clear_menu (hMenu) ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetFileMenu), "&File") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetEditMenu), "&Edit") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetSearchMenu), "Se&arch") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetTextMenu), "&Text") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetOptionsMenu), "E&ditor") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetInsertMenu), "&Insert") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hRenderMenu, "&Render") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hOptionsMenu, "&Options") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hToolsMenu, "Too&ls") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) EditGetMenu (GetWindowMenu), "&Window") ;
AppendMenu (hMenu, MF_POPUP, (UINT_PTR) hHelpMenu, "&Help") ;
DrawMenuBar (main_window) ;
}
}
|