Automatic screenshot creator utility

From WxWiki
Jump to navigation Jump to search

For now, this article is used by Utensil to

  1. report the progress of developing this utility.
  2. discuss the protocol about consistent appearance of the controls in this util and wx convention involved etc.
  3. post questions for wx-devs especially tierra and frm.

In future, this article might be used as official online manual of this utility.

The screenshot taking task was first suggested here , read it for more information. Also check out the forum thread with discussion about this utility.

General

For now, Utensil is working on writing something which will come in handy as soon as possible, to facilitate the screenshot taking process for volunteers, especially in providing consistent labels etc.

The automatical thing is on its way. See section "Progress of Automatical Part".

The current download is available on http://forums.wxwidgets.org/viewtopic.php?p=79840

How to use it?

Please read the following instruction before using it to take screenshots:

NOTE: The screenshots will be generated under sub-directory "screenshots" silently. Please monitor this folder before taking screenshots using "File->See screeshots".

1) The menu "Capture->Full screen" can take a screeshot for the fullscreen. It's designed for testing purpose only.

2) And then the semi-auto part. It works like you are using HyperSnap to Capture a region.

  • "Capture->Regions<Begin>" to begin taking screenshots for controls.
  • For example, you wanna take a screenshot for wxButton, you drag a rectangular region around it with some boarder, the moment you release your button, a png named "button.png" will be generated silently. This is the smart part, my program can recognize the control name in the region----if the midpoint of the region is on it. This is designed for the fully auto thing in the future. More feature and more AI will be added into this part.
  • You can continue to drag other rect regions for other controls without hitting the menu again, you can also turn pages of wxNotebook. When you finish, hit "Capture->Regions<End>".
  • I've generated screenshots of most of the controls in my program in less than a minute with the proper file names. There are some bugs for some controls so far, but I will fix them later.

3) Finnally the full-auto mode: "Capture->Capture All" or Ctrl+Alt+A, all the screenshots will be generated correctly under the subdirectory "screenshots".

Progress of Controls

Update 2008/04/19: Sorry for a long suspend of this util.

1) Adapted the wxOwnerDrawnComboBox sample and added it.

2) Trying svn check out wxWidgets in a unix partition to be shared by both Ubuntu and Mac OS.

3) Fixed the folowing bugs on Mac OS:

  • wxComboBox didn't selected the first item

4) The bugs remaining on Mac OS:

  • wxGuage looks too tiny and it changed to a vertical one
  • wxListCtrl completely empty and causes CRASH when clicked in it

Update 2008/04/04: Program ported to Mac OS X. Program works, but 1)wxTreeCtrl is too narrow 2) wxGuage 3)wxNotebook doesn't have enough room...

Update2008/03/23 09:00am: Program ported to Ubuntu 7.10. Program works. But 1)some controls are too dead when no cursor's on it, e.g wxScrollBar,wxSlider 2)it's difficult to choose how to take the screenshot for some controls due to the layout problem, e.g. wxDirPickCtrl. Still working on it.

Update2008/03/22 11:00am: Every control will try to display a string indicating the class name, by displaying it in a label or a tooltip. This is done for the volenteer to know the control's name. Read the source comments for more infomation.

[*]: Supported by wxFormBuilder

[#]: Done

[@]: Make use of the official sample or the sample in wxDoc

[!]: Only supported by 2.9.0

1)Needs One Label //Just use the class name

wxButton * #
wxCheckBox * #
wxStaticText * #
wxRadioButton * #
wxStaticBox #

2)Needs A Label Group // Use the pattern like “Choice1” “Item1” “Node1”.

wxChoice * #
wxCheckListBox * #
wxListBox * #
wxRadioBox * #
wxTreeCtrl * #
wxComboBox * #

3)Needs One Image // The official sign of wxWidgets.

wxBitmapButton * #
wxBitmapToggleButton //FIXME: Seems not implemeted by 2.9.0 yet.
wxStaticBitmap * #

3)Needs A Image List //@

wxBitmapComboBox

wxListCtrl #  * //For such a complicated class, choose which flag to display? Leave default style wxLC_ICON. Not Satisfactory.

wxListView 

4)Needs A GIF //@

wxAnimationCtrl

5)Needs A Range And A Current Value  //100 and 50

wxGauge * #
wxSlider * #

6)Needs Nothing //DOUBT:Is the appearance of dialog needed or just the control?

wxColourPickerCtrl * #
wxDirPickerCtrl * # //DOUBT: There are three statuses of it on Ubuntu!! Button, Menu, Dialog...
wxFilePickerCtrl * #
wxFontPickerCtrl * #//It will show the default font
wxGenericDirCtrl * #

7)Needs A Status

wxToggleButton * # //Toggled

8)Needs Text Or RichText

wxTextCtrl * #// multi-line under single-line in the same png.
wxRichTextCtrl * #// How to keep it in a reasonable size? Put the sample contents written by the author Julian Smart in it, and scroll to a proper position.

9)Needs A Date----Some special day in wx history?

wxDatePickerCtrl * #
wxCalendarCtrl * #

10)Needs Nothing Too

wxScrollBar * #
wxSpinButton * #
wxSpinCtrl *#

11)Needs HTML Styled Tags//@

wxHtmlListBox
wxSimpleHtmlListBox

12)Needs A URL // http://www.wxWidgets.org

wxHyperlinkCtrl * #

13)Needs A Customized Control To Popout  
wxComboCtrl # 

//@Used the minimal class wxListViewComboPopup given in wxDoc.
//But not satisfactory 

//@ Should make use of the greatly nice sample in wxWidgets/samples/combo

14)Needs A Derived Class //How to? A teammate is especially needed here

wxVListBox  //Variable, it has pure virtual functions
wxOwnerDrawnComboBox #//@ Should make use of the greatly nice sample in wxWidgets/samples/combo

15)Needs Something To Put In //Have no idea

wxCollapsiblePane // @DOUBT: How to display it? One collapsed and one not stand shoulder by shoulder?


16)Needs Somebody To Tell Me What They Need..// a bitmap, a date, a progress indicator, a label and a toggle??

wxDataViewCtrl
wxDataViewTreeCtrl

Progress of Automatical Part

2008-08-06

WIth the help of the following bug list, inspired by Auria's idea and work, the autocapture framework is finally established. For more info, just refer to http://forums.wxwidgets.org/viewtopic.php?t=18468 .

Every control listed below will be folowing by three marks, representing the status(# for OK, //@ for size BUG, //* for filename BUG) on three paltforms(MSW,GTK,MAC) respectively.

The status is whether the screenshots are generated correctly. So far, only Windows and Ubuntu are tested and marked.

wxButton
#
#
wxStaticText
#
#
wxCheckBox
#
#
wxRadioButton
#
#
wxBitmapButton
#
#
wxStaticBitmap
#
#
wxGauge
//* gauge95
#
wxSlider
#
#
wxToggleButton
#
#
wxHyperlinkCtrl
#
#
wxSpinCtrl
//@ on its right side
#
wxSpinButton
#
#
wxScrollBar
#
#
wxCheckListBox
#
#
wxListBox
#
#
wxRadioBox
#
#
wxStaticBox
//* //@ Unable to get it at all, will result in panel
#
wxTreeCtrl
#
#
wxListCtrl
#
//* will result in "listmainwindow"(under 2.8.7) or "window"(under 2.9.0)
wxChoice
//@ How to pop out?
//@ How to pop out?
wxComboBox
//@ How to pop out?
//@ How to pop out?
wxTextCtrl
//@ But not getting both two ctrls yet.
//@ But not getting both two ctrls yet.
wxRichTextCtrl
#
#
wxColourPickerCtrl
#
//* will result in colourbutton
wxFontPickerCtrl
#
//* will result in fontbutton
wxFilePickerCtrl
//@ //* Unable to get it at all, will result in textctrl
//* will result in filebutton
wxCalendarCtrl
//@ Lost the wxChoice and wxSpinCtrl on the top
//@ Size right but position bottom (But under 2.9.0, //* gtkcalendarctrl, and no size problem)
wxDatePickerCtrl
#
//* will result in textctrl and lose the down arrow
wxDirPickerCtrl
//@ //* Unable to get it at all, will result in textctrl
//* will result in dirbutton
wxGenericDirCtrl
//* Will result in treectrl
//* Will result in treectrl
wxBitmapComboBox
//@ //* will result in textctrl, lost other parts.
//@ //* will result in textctrl, lost other parts.
wxComboCtrl
//@ //* will result in textctrl, lost other parts.
//@ //* will result in textctrl, lost other parts.
wxOwnerDrawnComboBox
#
#

Update 2008/5/10:

Added multi-point mechanism to detect the control chosen, the size and name of it.

Improvements in return:

1) Now one png can contain more than one controls which are of the same type.e.g. two textctrls will be safely save to a textctrl.png

2) Names of multi-type of window detected will be named using '_' to join, sizes of them will be unioned. e.g. a bitmap combobox will be saved as textctrl_bitmapcombobox.png, losing no part of it.

3) If only wxPanel detected, will save the screenshot of the mannual specified rect(instead of the real size of the control) to unknown.png

Used wxAuiNotebook, to make the panels deletable.

Update 2008/04/29: Compiled it against 2.9.0 under Ubuntu. Confirm the annoying bug spoted by frm: "Image type is not the type of 15" and it seems to be casued by richtextctrl.xml:

<image imagetype="15">  <data>89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7AF40000000473424954080808087C0864880000013A494441545885ED57D116C2200845D787EDD3F763450FC622075E3477D643BC5483EEBD03454C292F74A5DD46FEC48F3BD7CF525ED2A90234291FE889527AFB7BC424540221B6487DD0B8908CC899FBC8894A3CB35DAADACC0C8CBCB54FF0FA74B2E1666006B9E0B4B271102069B72C818A223F1480C8997D12E4F7B2D05C8435B800D524C8DF12B10BF0DE5E836B20F43B5A0E98010DDEB306A28B385482332D13B5179F361413C5D0EBE03732F01780ACB7C3F5C467A2725044B6D8B41875308507924D0110D9FD4162D62868548074B6CD10A28985BC6F7851F300EA0722C2B308F97009883E7BBC16B22A7F0F7979564D44D1AED8DBF72D7222631B467684908ECC8B50C02E6468CAB771BCB72FFEC6581E2D47931C8CE6CD4E28E518E98411F2121BBC1BE29B91FA3EF36684C48C907E2D60A65D7E1C3F01DF3DAE9FE1B576060000000049454E44AE426082</data>
</image>

which is the image of wxWidgets sign. But it works fine under 2.8.7.

Updated some bug descriptions to reflect the status under 2.9.0.

Update 2008/04/28: Tested it under Ubuntu. The visualizing part failed under it. The mask isn't transparent and it will affect the process of taking the screenshots.

Update 2008/04/27:

Visualize the dragging process with the help of Bryan :)

Tested it under Windows.

2008/04/04 Program ported to Mac OS X. Catastrophe! It's confirmed that bliting wxScreenDC and wxClientDC only results in failure on Mac :(

2008/04/01 05:30am

  1. The automatical part ported to Ubuntu.
  2. Unable to install gcc under Mac OS X due to the super low speed of downloading XCode :(
  3. BUG: The wxRTTI of wxBitmapComboBox and wxComboCtrl always report that they are wxTextCtrl...

2008/03/28 03:25am

  1. Function of capturing fullscreen is added to test whether the screnshot can be taken under the current platform, due to the possible failure under Mac OS mentioned by Auria.
  2. Function of capturing manually specified rectangular regions added. Also it implemented the auto-saving function----e.g. if the rectangular region contains wxButton, it will 1)get its name from wxRTTI, 2)cut off "wx" and make it lowercase, 3) save it as "button.png" according to the naming convention of docscreenshots.

Questions and Unclear Doubts

  1. The doubts mentioned in Progress of Controls
  2. Is it needed to erase the trace of wxFormBuilder when this util is done?
  3. Is it needed to merge the source code into ONE file when this util is done?
  4. Where to upload this util during developing?
  5. Is the class name wxScreenshot OK? How about the header and implementation name? I didn’t follow the wx sample convention since I didn’t know how to name them…

Bakefile Issues

The bakefile is written for cross-platform compiling purpose as follows:

<?xml version="1.0" ?>
<makefile>

    <include file="../../build/bakefiles/common_samples.bkl"/>

    <exe id="wxScreenshot" template="wx_sample" template_append="wx_append">
        <syntaxhighlights>GUIFrame.cpp</syntaxhighlights>
        <syntaxhighlights>wxScreenshotApp.cpp</syntaxhighlights>
        <syntaxhighlights>wxScreenshotMain.cpp</syntaxhighlights>
        <wx-lib>core</wx-lib>
        <wx-lib>base</wx-lib>
        <wx-lib>richtext</wx-lib>
        <wx-lib>xml</wx-lib>
        <wx-lib>adv</wx-lib>
        <win32-res>resource.rc</win32-res>
    </exe>

    <wx-data id="data">
        <files>
            richtext.xml
            wxwin32x32.png
            bell.png
            info.png
            sound.png
        </files>
    </wx-data>

</makefile>

but how to use it to copy a directory(might create one during donging that)? Because I don’t like the png files spreading around the source.