mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
GrabYourScreen: Improved and included basic doc
git-svn-id: svn://ultimatepp.org/upp/trunk@9325 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6f92fbab67
commit
09780dd2ef
8 changed files with 122 additions and 57 deletions
|
|
@ -13,7 +13,7 @@ void GrabBook::Init() {
|
|||
down <<= 900;
|
||||
split = true;
|
||||
|
||||
folder = AppendFileName(GetDesktopFolder(), "Libro");
|
||||
folder = AppendFileName(GetDesktopFolder(), t_("Book"));
|
||||
|
||||
canvas.SetShowWindow(false);
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ void GrabBook::OnCapture() {
|
|||
Rect screenRect;
|
||||
::GetWindowRect(GetHWND(), screenRect);
|
||||
if (rPdf.Intersects(screenRect)) {
|
||||
Exclamation("Ventana del programa interfiere con imagen a tomar");
|
||||
Exclamation(t_("Program window interferes with image"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ void GrabBook::OnCapture() {
|
|||
if (!DirectoryExists(folder))
|
||||
RealizeDirectory(folder);
|
||||
Image img = ::GetRect(canvas.GetBackground(), Rect(left, up, right, down));
|
||||
if (!SaveImage(img, 100, AppendFileName(folder, Format("Pag%04d.jpg", int(actualPage))), ".jpg"))
|
||||
Exclamation("Error saving image");
|
||||
if (!SaveImage(img, 100, AppendFileName(folder, Format("%s.jpg", Format(t_("Pag%04d"), int(actualPage))))))
|
||||
Exclamation(t_("Error saving image"));
|
||||
actualPage = actualPage + 1;
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ void GrabBook::OnSavePDF() {
|
|||
FileSel fs;
|
||||
|
||||
fs.ActiveDir(GetDesktopFolder());
|
||||
fs.Type("Ficheros PDF", ".pdf");
|
||||
fs.Type(t_("PDF files"), ".pdf");
|
||||
|
||||
if (fs.ExecuteSaveAs(t_("Saving file")))
|
||||
fileName = ~fs;
|
||||
|
|
@ -96,7 +96,7 @@ void GrabBook::OnSavePDF() {
|
|||
if (i > 0)
|
||||
r.NewPage();
|
||||
|
||||
String fileName = AppendFileName(folder, Format("Pag%04d.jpg", i));
|
||||
String fileName = AppendFileName(folder, Format("%s.jpg", Format(t_("Pag%04d"), i)));
|
||||
Image img = StreamRaster::LoadFileAny(fileName);
|
||||
Image imgIzq, imgDer;
|
||||
if (split) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "GrabYourScreen.h"
|
||||
|
||||
#include <plugin/jpg/jpg.h>
|
||||
|
||||
GrabScreen::GrabScreen() {
|
||||
CtrlLayout(*this);
|
||||
}
|
||||
|
|
@ -7,6 +9,7 @@ GrabScreen::GrabScreen() {
|
|||
void GrabScreen::Init(GrabYourScreen &_program) {
|
||||
program = &_program;
|
||||
editFileNameGrab <<= AppendFileName(GetDesktopFolder(), "ScreenGrab.avi");
|
||||
editFileNameGrab.Type(t_("Video file"), ".avi");
|
||||
editTime <<= 5;
|
||||
editFrameRate <<= 1;
|
||||
opGrabMouse <<= true;
|
||||
|
|
@ -37,24 +40,27 @@ void GrabScreen::Init(GrabYourScreen &_program) {
|
|||
height.Hide();
|
||||
#endif
|
||||
|
||||
editLeft <<= 100;
|
||||
editWidth <<= 1000;
|
||||
editTop <<= 100;
|
||||
editHeight <<= 900;
|
||||
|
||||
String extension;
|
||||
#if defined(PLATFORM_WIN32)
|
||||
extension = "bmp";
|
||||
#else
|
||||
extension = "xwd";
|
||||
#endif
|
||||
editFileNameSnap <<= AppendFileName(GetDesktopFolder(), "ScreenSnap." + extension);
|
||||
editFileNameSnap <<= AppendFileName(GetDesktopFolder(), "ScreenSnap.jpg");
|
||||
editFileNameSnap.Type(t_("Image file"), ".jpg");
|
||||
butSnap.WhenPush = THISBACK(ButSnap_Push);
|
||||
|
||||
Array<int64> hWnd, processId;
|
||||
Array<String> name, fileName, caption;
|
||||
GetWindowsList(hWnd, processId, name, fileName, caption);
|
||||
GetWindowsList(hWnd, processId, name, fileName, caption, false);
|
||||
Sort(caption);
|
||||
for (int i = 0; i < caption.GetCount(); ++i) {
|
||||
if (!Trim(caption[i]).IsEmpty())
|
||||
editWindowTitle.Add(caption[i]);
|
||||
}
|
||||
editWindowTitle.SetData(editWindowTitle.GetValue(0));
|
||||
|
||||
SetTimeCallback(-1000, THISBACK(Timer));
|
||||
}
|
||||
|
||||
void GrabScreen::SwGrabMode_Action() {
|
||||
|
|
@ -102,41 +108,49 @@ void GrabScreen::ButGrab_Push() {
|
|||
}
|
||||
|
||||
void GrabScreen::ButSnap_Push() {
|
||||
program->Minimize();
|
||||
/* program->Minimize();
|
||||
|
||||
TopWindow win;
|
||||
Button b;
|
||||
b.SetLabel("CLOSE");
|
||||
b <<= win.Breaker();
|
||||
StaticImage image;
|
||||
image.Set(Snap_Desktop());
|
||||
win.Add(image.SizePos());
|
||||
StaticImage desktop;
|
||||
desktop.Set(Snap_Desktop());
|
||||
win.Add(desktop.SizePos());
|
||||
win.Add(b.LeftPos(10, 100).TopPos(10, 30));
|
||||
|
||||
win.FullScreen().Run();
|
||||
|
||||
program->Overlap();
|
||||
return;
|
||||
*/
|
||||
String fileName = ~editFileNameSnap;
|
||||
FileDelete(fileName);
|
||||
|
||||
String ext = GetFileExt(fileName);
|
||||
|
||||
|
||||
FileDelete(editFileNameSnap.GetData().ToString());
|
||||
|
||||
if (swGrabMode.GetData() == 0)
|
||||
Snap_Desktop(editFileNameSnap);
|
||||
else if (swGrabMode.GetData() == 1)
|
||||
Snap_Window(editFileNameSnap, GetWindowIdFromCaption(~editWindowTitle, false));
|
||||
else if (swGrabMode.GetData() == 2)
|
||||
Snap_DesktopRectangle(editFileNameSnap, editLeft, editTop, editWidth, editHeight);
|
||||
else
|
||||
throw Exc("Unexpected value");
|
||||
if (ext == ".png") {
|
||||
PNGEncoder encoder;
|
||||
if (!encoder.SaveFile(fileName, canvasImage))
|
||||
Exclamation(Format(t_("Impossible to save %s"), fileName));
|
||||
} else if (ext == ".jpg") {
|
||||
JPGEncoder encoder(90);
|
||||
if (!encoder.SaveFile(fileName, canvasImage))
|
||||
Exclamation(Format(t_("Impossible to save %s"), fileName));
|
||||
} else
|
||||
Exclamation(Format(t_("File format \"%s\" not found"), ext));
|
||||
}
|
||||
|
||||
/*
|
||||
A añadir:
|
||||
- Listado de ventanas en Window Title
|
||||
- Pantalla completa para seleccionar. Meterlo en Controls4U
|
||||
- Jsonize para todos
|
||||
- Que deje salir si un campo está vacio
|
||||
- Ficheros con EditFile
|
||||
*/
|
||||
void GrabScreen::Timer() {
|
||||
NON_REENTRANT_V;
|
||||
|
||||
switch(int(~swGrabMode)) {
|
||||
case 0: canvasImage = Snap_Desktop();
|
||||
break;
|
||||
case 1: canvasImage = Snap_Window(GetWindowIdFromCaption(~editWindowTitle, false));
|
||||
break;
|
||||
case 2: canvasImage = Snap_DesktopRectangle(editLeft, editTop, editWidth, editHeight);
|
||||
break;
|
||||
}
|
||||
|
||||
canvas.SetBackground(canvasImage);
|
||||
}
|
||||
|
|
@ -20,12 +20,15 @@ public:
|
|||
GrabScreen();
|
||||
|
||||
void Init(GrabYourScreen &program);
|
||||
|
||||
private:
|
||||
void ButGrab_Push();
|
||||
void ButSnap_Push();
|
||||
void SwGrabMode_Action();
|
||||
|
||||
private:
|
||||
void Timer();
|
||||
|
||||
GrabYourScreen *program;
|
||||
Image canvasImage;
|
||||
};
|
||||
|
||||
class GrabBook : public WithBook<StaticRect> {
|
||||
|
|
@ -33,8 +36,10 @@ public:
|
|||
typedef GrabBook CLASSNAME;
|
||||
GrabBook();
|
||||
~GrabBook();
|
||||
|
||||
|
||||
void Init();
|
||||
|
||||
private:
|
||||
void OnPaint(Painter &painter);
|
||||
void OnReset();
|
||||
void OnCapture();
|
||||
|
|
@ -49,7 +54,10 @@ class GrabYourScreen : public TopWindow {
|
|||
public:
|
||||
typedef GrabYourScreen CLASSNAME;
|
||||
GrabYourScreen();
|
||||
|
||||
void Init();
|
||||
|
||||
private:
|
||||
void Exit();
|
||||
|
||||
TabCtrl mainTab;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ LAYOUT(Book, 368, 292)
|
|||
ITEM(Option, split, SetLabel(t_("Split in two")).RightPosZ(4, 84).TopPosZ(136, 16))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(Screen, 464, 204)
|
||||
LAYOUT(Screen, 464, 352)
|
||||
ITEM(LabelBox, dv___0, SetLabel(t_("Image Snapshot")).LeftPosZ(8, 452).TopPosZ(68, 40))
|
||||
ITEM(LabelBox, dv___1, SetLabel(t_("Video Grab")).LeftPosZ(8, 452).TopPosZ(4, 60))
|
||||
ITEM(LabelBox, dv___2, SetLabel(t_("Mode")).LeftPosZ(8, 452).TopPosZ(112, 84))
|
||||
|
|
@ -26,18 +26,18 @@ LAYOUT(Screen, 464, 204)
|
|||
ITEM(Label, top, SetLabel(t_("Top:")).LeftPosZ(176, 24).TopPosZ(168, 19))
|
||||
ITEM(Label, width, SetLabel(t_("Width:")).LeftPosZ(256, 36).TopPosZ(168, 19))
|
||||
ITEM(Label, height, SetLabel(t_("Height:")).LeftPosZ(348, 40).TopPosZ(168, 19))
|
||||
ITEM(EditString, editFileNameSnap, NotNull(true).LeftPosZ(72, 316).TopPosZ(84, 19))
|
||||
ITEM(EditString, editFileNameGrab, NotNull(true).LeftPosZ(72, 316).TopPosZ(20, 19))
|
||||
ITEM(EditFile, editFileNameSnap, LeftPosZ(72, 316).TopPosZ(84, 19))
|
||||
ITEM(EditFile, editFileNameGrab, LeftPosZ(72, 316).TopPosZ(20, 19))
|
||||
ITEM(EditIntNotNull, editTime, Min(1).LeftPosZ(72, 32).TopPosZ(40, 19))
|
||||
ITEM(EditDoubleNotNull, editFrameRate, LeftPosZ(196, 24).TopPosZ(40, 19))
|
||||
ITEM(Option, opGrabMouse, SetLabel(t_("Grab mouse")).LeftPosZ(288, 76).TopPosZ(44, 16))
|
||||
ITEM(Switch, swGrabMode, LeftPosZ(16, 80).TopPosZ(128, 64))
|
||||
ITEM(EditInt, editLeft, Min(0).LeftPosZ(120, 44).TopPosZ(168, 19))
|
||||
ITEM(EditInt, editTop, Min(0).LeftPosZ(200, 44).TopPosZ(168, 19))
|
||||
ITEM(EditInt, editWidth, Min(0).LeftPosZ(292, 44).TopPosZ(168, 19))
|
||||
ITEM(EditInt, editHeight, Min(0).LeftPosZ(388, 44).TopPosZ(168, 19))
|
||||
ITEM(EditIntSpin, editLeft, Min(0).LeftPosZ(120, 48).TopPosZ(168, 19))
|
||||
ITEM(EditIntSpin, editTop, Min(0).LeftPosZ(200, 48).TopPosZ(168, 19))
|
||||
ITEM(EditIntSpin, editWidth, Min(0).LeftPosZ(292, 48).TopPosZ(168, 19))
|
||||
ITEM(EditIntSpin, editHeight, Min(0).LeftPosZ(388, 48).TopPosZ(168, 19))
|
||||
ITEM(Label, left, SetLabel(t_("Left:")).LeftPosZ(96, 24).TopPosZ(168, 19))
|
||||
ITEM(Label, dv___18, SetLabel(t_("Window Title:")).LeftPosZ(96, 64).TopPosZ(148, 19))
|
||||
ITEM(Label, dv___18, SetLabel(t_("Window Title:")).LeftPosZ(96, 76).TopPosZ(148, 19))
|
||||
ITEM(Label, dv___19, SetLabel(t_("File Name:")).LeftPosZ(16, 52).TopPosZ(84, 19))
|
||||
ITEM(Label, dv___20, SetLabel(t_("File Name:")).LeftPosZ(16, 52).TopPosZ(20, 19))
|
||||
ITEM(Button, butSnap, SetLabel(t_("Snap it!")).LeftPosZ(392, 56).TopPosZ(84, 20))
|
||||
|
|
@ -45,6 +45,7 @@ LAYOUT(Screen, 464, 204)
|
|||
ITEM(Label, dv___23, SetLabel(t_("Frame rate:")).LeftPosZ(140, 56).TopPosZ(40, 19))
|
||||
ITEM(Label, dv___24, SetLabel(t_("sec")).LeftPosZ(104, 24).TopPosZ(40, 19))
|
||||
ITEM(Label, dv___25, SetLabel(t_("Time:")).LeftPosZ(16, 52).TopPosZ(40, 19))
|
||||
ITEM(DropList, editWindowTitle, LeftPosZ(164, 268).TopPosZ(148, 19))
|
||||
ITEM(DropList, editWindowTitle, LeftPosZ(172, 264).TopPosZ(148, 19))
|
||||
ITEM(PainterCanvas, canvas, SetShowWindow(false).SetFrame(ThinInsetFrame()).HSizePosZ(4, 4).VSizePosZ(200, 4))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ file
|
|||
GrabYourScreen.h,
|
||||
GrabYourScreen.lay,
|
||||
iml.iml,
|
||||
rc.rc;
|
||||
rc.rc,
|
||||
srcdoc.tpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI SSE2";
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
|
@ -14,10 +14,13 @@ void GrabYourScreen::Init() {
|
|||
Title("GrabYourScreen");
|
||||
|
||||
Add(mainTab.SizePos());
|
||||
grabBook.Init();
|
||||
mainTab.Add(grabBook.SizePos(), "Book");
|
||||
|
||||
grabScreen.Init(*this);
|
||||
mainTab.Add(grabScreen.SizePos(), "Screen");
|
||||
mainTab.Add(grabScreen.SizePos(), t_("Screen"));
|
||||
grabBook.Init();
|
||||
mainTab.Add(grabBook.SizePos(), t_("Book"));
|
||||
Rect rect = GetRect();
|
||||
SetRect(rect.left, rect.top, 500, 500);
|
||||
}
|
||||
|
||||
void GrabYourScreen::Exit() {
|
||||
|
|
@ -25,8 +28,12 @@ void GrabYourScreen::Exit() {
|
|||
}
|
||||
|
||||
GUI_APP_MAIN {
|
||||
GrabYourScreen program;
|
||||
program.Open();
|
||||
program.Init();
|
||||
program.Run();
|
||||
try {
|
||||
GrabYourScreen program;
|
||||
program.Open();
|
||||
program.Init();
|
||||
program.Run();
|
||||
} catch(Exc error) {
|
||||
Exclamation(Format(t_("Error %s"), error));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
34
bazaar/GrabYourScreen/srcdoc.tpp/GarbYourScreen$en-us.tpp
Normal file
34
bazaar/GrabYourScreen/srcdoc.tpp/GarbYourScreen$en-us.tpp
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue