This commit is contained in:
rods 1998-05-08 15:06:41 +00:00
Родитель 9fbed3223c
Коммит 7feb35813c
3 изменённых файлов: 120 добавлений и 7 удалений

Просмотреть файл

@ -50,4 +50,10 @@
#define JS_CONSOLE 40100 #define JS_CONSOLE 40100
#define VIEWER_EDIT_CUT 40201
#define VIEWER_EDIT_COPY 40202
#define VIEWER_EDIT_PASTE 40203
#define VIEWER_EDIT_SELECTALL 40204
#define VIEWER_EDIT_FINDINPAGE 40205
#endif /* resources_h___ */ #endif /* resources_h___ */

Просмотреть файл

@ -45,6 +45,17 @@ VIEWER MENU DISCARDABLE
} }
MENUITEM "&Exit", VIEWER_EXIT MENUITEM "&Exit", VIEWER_EXIT
} }
POPUP "&Edit"
BEGIN
MENUITEM "Cu&t", VIEWER_EDIT_CUT, GRAYED
MENUITEM "&Copy", VIEWER_EDIT_COPY
MENUITEM "&Paste", VIEWER_EDIT_PASTE, GRAYED
MENUITEM SEPARATOR
MENUITEM "Select &All", VIEWER_EDIT_SELECTALL, HELP
MENUITEM SEPARATOR
MENUITEM "&Find in Page", VIEWER_EDIT_FINDINPAGE
, GRAYED
END
POPUP "&Debug" POPUP "&Debug"
{ {
MENUITEM "&Visual Debugging", VIEWER_VISUAL_DEBUGGING MENUITEM "&Visual Debugging", VIEWER_VISUAL_DEBUGGING

Просмотреть файл

@ -49,6 +49,11 @@
#include "nsIScriptContext.h" #include "nsIScriptContext.h"
#include "nsDocLoader.h" #include "nsDocLoader.h"
// Selection Repaint includes
#include "nsIPresShell.h"
#include "nsIFrame.h"
#include "nsIViewManager.h"
// JSConsole window // JSConsole window
JSConsole *gConsole = NULL; JSConsole *gConsole = NULL;
@ -292,6 +297,80 @@ OpenHTMLFile(WindowData* wd)
} }
} }
// Selects all the Content
static void
SelectAll(WindowData* wd)
{
if (wd->ww != nsnull) {
nsIDocument* doc = wd->ww->GetDocument();
if (doc != nsnull) {
doc->SelectAll();
wd->ww->ShowFrameBorders(PR_FALSE);
/*PRInt32 numShells = doc->GetNumberOfShells();
for (PRInt32 i=0;i<numShells;i++) {
nsIPresShell * shell = doc->GetShellAt(i);
//nsIViewManager * viewMgr = shell->GetViewManager();
nsIFrame * frame = shell->GetRootFrame();
nsRect rect;
nsIView * view;
nsPoint pnt;
frame->GetOffsetFromView(pnt, view);
frame->GetRect(rect);
rect.x = pnt.x;
rect.y = pnt.y;
if (view != nsnull) {
nsIViewManager * viewMgr = view->GetViewManager();
if (viewMgr != nsnull) {
viewMgr->UpdateView(view, rect, 0);
}
}
NS_IF_RELEASE(shell);
//NS_IF_RELEASE(frame);
}*/
NS_IF_RELEASE(doc);
}
}
}
// Selects all the Content
static void
CopyTextContent(WindowData* wd, HWND aHWnd)
{
HGLOBAL hGlobalMemory;
PSTR pGlobalMemory;
if (wd->ww != nsnull) {
nsIDocument* doc = wd->ww->GetDocument();
if (doc != nsnull) {
// Get Text from Selection
nsString text;
doc->GetSelectionText(text);
// Copy text to Global Memory Area
hGlobalMemory = (HGLOBAL)GlobalAlloc(GHND, text.Length()+1);
if (hGlobalMemory != NULL) {
pGlobalMemory = (PSTR) GlobalLock(hGlobalMemory);
char * str = text.ToNewCString();
char * s = str;
for (int i=0;i<text.Length();i++) {
*pGlobalMemory++ = *s++;
}
delete str;
// Put data on Clipboard
GlobalUnlock(hGlobalMemory);
OpenClipboard(aHWnd);
EmptyClipboard();
SetClipboardData(CF_TEXT, hGlobalMemory);
CloseClipboard();
}
NS_IF_RELEASE(doc);
}
}
}
long PASCAL long PASCAL
WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam) WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
{ {
@ -319,6 +398,23 @@ WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam)
OpenHTMLFile(wd); OpenHTMLFile(wd);
break; break;
case VIEWER_EDIT_CUT:
break;
case VIEWER_EDIT_COPY:
CopyTextContent(wd, hWnd);
break;
case VIEWER_EDIT_PASTE:
break;
case VIEWER_EDIT_SELECTALL:
SelectAll(wd);
break;
case VIEWER_EDIT_FINDINPAGE:
break;
case VIEWER_DEMO0: case VIEWER_DEMO0:
case VIEWER_DEMO1: case VIEWER_DEMO1:
case VIEWER_DEMO2: case VIEWER_DEMO2: