Submenu of a wxMenuItem - wxwidgets

I wanted to have a submenu manually append to a submenu("History") under "Edit"
wxMenuBar * menubara = GetMenuBar();
wxMenu * menua = menubara->GetMenu(1);
wxInt32 menuIda = menua->FindItem(wxT("History"));
wxMenuItem * menuItema = menua->FindItem(menuIda);
This is how I get History as a wxMenuItem. However, there is no addSubMenu for wxMenuItem. How can I add a submenu to History?

From my memory, so I might be wrong: you have to create another menu (if it does not already have it, get it with GetSubMenu), insert a new menu item for the new entry and use wxMenuItem->SetSubMenu to set it.

Related

Set width of toolbar button defined in cl_gui_toolbar

I've got a toolbar defined with class cl_gui_toolbar which is displayed in a container (which got created via class cl_gui_custom_container). I've added some buttons and button groups into it.
Now my user wants one of those button groups to be bigger, because the user might not recognize that the button is there. Is there any method to set the width of the button-group?
Here is my current code:
METHOD init_toolbar.
DATA: lt_buttons_data TYPE ttb_button,
ls_button_data TYPE LINE OF ttb_button.
go_toolbar_container = NEW cl_gui_custom_container( container_name = 'TOOLBAR_1000' ).
go_toolbar = NEW cl_gui_toolbar( parent = go_toolbar_container ).
" Some other buttons
" ...
" ...
CLEAR ls_button_data.
CLEAR lt_buttons_data.
ls_button_data-function = 'DBFILTER'.
ls_button_data-icon = '#EX#'.
ls_button_data-quickinfo = 'Quickinfo'.
ls_button_data-text = 'SmallText'.
ls_button_data-butn_type = cntb_btype_menu.
APPEND ls_button_data TO lt_buttons_data.
go_toolbar->add_button_group( data_table = lt_buttons_data ).
CLEAR ct_expand.
ct_expand = NEW cl_ctmenu( ).
ct_expand->add_function( fcode = '1' text = '1' checked = abap_false ).
ct_expand->add_function( fcode = '2' text = '2' checked = abap_false ).
ct_expand->add_function( fcode = '3' text = '3' checked = abap_false ).
CLEAR wa_ctxmenu.
wa_ctxmenu-function = 'DBFILTER'.
wa_ctxmenu-ctmenu = ct_expand.
APPEND wa_ctxmenu TO table_ctxmenu.
go_toolbar->assign_static_ctxmenu_table( table_ctxmenu = table_ctxmenu ).
ENDMETHOD.
Do you know a way how to set the width of this button-group?
PS: I just got the info, that the text of the button ( e. g. "smallText" ) can be replaced if a longer text, if there is no other way .
It's not possible to customize the width of a button in class CL_GUI_TOOLBAR as a number of pixels.
As a workaround:
Enter a longer text. Maybe enter "non-breaking spaces" at the end of your text. This is the Unicode character U+00A0 (CL_ABAP_CONV_IN_CE=>UCCP( '00A0' )).
Instead of CL_GUI_TOOLBAR, use the class CL_GUI_HTML_VIEWER to define the buttons with HTML code and CSS styles. But I doubt it's worth spending time for that.

QGroupBox sizing with my QT5 custom widget

I am trying to make a custom widget: for displaying a processor register which has a name, a value and can be displayed in octal/decimal hexa. The code is shown at the bottom. I receive better result when I use the code as shown (i.e I insert QRadioButtons):
If I use
mainLayout->addWidget(DisplayMode);
instead (I guess this is the correct method) then the resulting picture is
Do I misunderstand something? What is wrong?
RegisterWidget::RegisterWidget(QWidget *parent)
:QFrame (parent)
{
mValue = 0;
mName = "";
setFrameStyle(QFrame::Panel | QFrame::Sunken);
QHBoxLayout *mainLayout = new QHBoxLayout(this);
label = new QLabel(tr("mName"),this);
label->setText(mName);
label->setLineWidth(2);
QGroupBox *DisplayMode = new QGroupBox("");
QRadioButton *OctalR = new QRadioButton(this);
QRadioButton *DecimalR = new QRadioButton(this);
DecimalR->setChecked(true); DecimalR->setDown(true);
QRadioButton *HexaR = new QRadioButton(this);
QHBoxLayout *hbox = new QHBoxLayout;
hbox->addWidget(OctalR);
hbox->addWidget(DecimalR);
hbox->addWidget(HexaR);
hbox->addStretch(1);
DisplayMode->setLayout(hbox);
mainLayout->addWidget(label);
Value = new QLCDNumber(this);
Value->setDigitCount(8);
Value->setSegmentStyle(QLCDNumber::Flat);
Value->display(mValue);
mainLayout->addWidget(Value);
/* mainLayout->addWidget(DisplayMode);*/
mainLayout->addWidget(OctalR);
mainLayout->addWidget(DecimalR);
mainLayout->addWidget(HexaR);
setLineWidth(3);
setLayout(mainLayout);
connect(OctalR, SIGNAL(clicked()), this, SLOT(setOctal()));
connect(DecimalR, SIGNAL(clicked()), this, SLOT(setDecimal()));
connect(HexaR, SIGNAL(clicked()), this, SLOT(setHexa()));
}
Call QLayout::setContentsMargins() for both mainLayout and hbox. Try (3, 3, 3, 3) as parameters for a starting point and tweak. Layouts have default margins of 11 pixels on most platforms, according to the docs.

Displaying main report with subreport

The following is my code and it is working with only one report.
rptbill = New CrystalReport1
rptexp = New ExpensesReport
rptmain = New MAINREPORT
rptbill.SetDataSource(dtincom)
rptexp.SetDataSource(dtexp)
frmCrystalReport.CrystalReportViewer1.ReportSource = rptmain
What I want is that my rptmain shows the field of my submenus rptbill and rptexp. I don't know how to get this to work.

How to select a particular dynamic item from the list

This is my scenario:
create an id. (ID has a timestamp on it for the purpose of regression testing). For example abc_201502125566781. In other words, a unique id is created each time.
go to a different screen, select the same id in the pulldown menu, that was created in step 1. (Manual testing confirms that the id is available in the pulldown menu from step 1)
The following code works(not really), because it creates the new id in the search field, and grabs it, rather than the id from step 1 above. How can I tell the driver to grab the ID that was created in step 1. Thanks!
NOTE: domain_id has a timestamp assigned to it.
public static String domain_id = PropertyLoader.loadProperty("PVT_DOMAIN_ID") + now;
My code:
WebDriverWait wait = new WebDriverWait(driver, 60);
By xpath = By.xpath("//div[#id='overview_form']//select/option");
WebElement element = new WebDriverWait(driver,10).until(ExpectedConditions.presenceOfElementLocated(xpath));
element = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//option[.='" + domain_id + "']")));
String getThePreviouslyCreatedsiteId = element.getText().trim();
driver.findElement(By.xpath(PvtConstants.ADD_PAGE_SITES_PULLDOWN_SEARCH_FIELD)).sendKeys(getThePreviouslyCreatedsiteId);
driver.findElement(By.xpath(PvtConstants.ADD_PAGE_SITES_PULLDOWN_SEARCH_FIELD)).sendKeys(Keys.ENTER);
STEP 1:
/*1. From Left Navigation bar, select Setup > Sites*/
setup.setUp();
siteClickFromLeftHandMenu();
/*2. Click the +Add button*/
clickToAddNewSiteButton();
/*3. On Add/Edit Site screen, enter a valid Site ID (i.e. Site_timestamp) and click Add.*/
driver.findElement(By.xpath(PvtConstants.ADD_SITE_ID)).sendKeys(site_id);
verifyDisplay(site_id + "", By.xpath(PvtConstants.ADD_SITE_ID));
/*4. Enter the same value as domain.*/
driver.findElement(By.xpath(PvtConstants.ADD_SITE_DOMAIN)).sendKeys(domain_id);
verifyDisplay(domain_id + "", By.xpath(PvtConstants.ADD_SITE_DOMAIN));
driver.findElement(By.xpath(PvtConstants.ADD_SITE_DOMAIN)).getText();
//click to add the site
clickAddToAddSiteInTheAccount();
/*5. The message "Successfully Added" is displayed.*/
verifyDisplay("Successfully added.", By.id(PvtConstants.ADD_SITE_SUCCESSFULLY_ADDED_MESSSAGE));

How to get an outline view in sublime texteditor?

How do I get an outline view in sublime text editor for Windows?
The minimap is helpful but I miss a traditional outline (a klickable list of all the functions in my code in the order they appear for quick navigation and orientation)
Maybe there is a plugin, addon or similar? It would also be nice if you can shortly name which steps are neccesary to make it work.
There is a duplicate of this question on the sublime text forums.
Hit CTRL+R, or CMD+R for Mac, for the function list. This works in Sublime Text 1.3 or above.
A plugin named Outline is available in package control, try it!
https://packagecontrol.io/packages/Outline
Note: it does not work in multi rows/columns mode.
For multiple rows/columns work use this fork:
https://github.com/vlad-wonderkidstudio/SublimeOutline
I use the fold all action. It will minimize everything to the declaration, I can see all the methods/functions, and then expand the one I'm interested in.
I briefly look at SublimeText 3 api and view.find_by_selector(selector) seems to be able to return a list of regions.
So I guess that a plugin that would display the outline/structure of your file is possible.
A plugin that would display something like this:
Note: the function name display plugin could be used as an inspiration to extract the class/methods names or ClassHierarchy to extract the outline structure
If you want to be able to printout or save the outline the ctr / command + r is not very useful.
One can do a simple find all on the following grep ^[^\n]*function[^{]+{ or some variant of it to suit the language and situation you are working in.
Once you do the find all you can copy and paste the result to a new document and depending on the number of functions should not take long to tidy up.
The answer is far from perfect, particularly for cases when the comments have the word function (or it's equivalent) in them, but I do think it's a helpful answer.
With a very quick edit this is the result I got on what I'm working on now.
PathMaker.prototype.start = PathMaker.prototype.initiate = function(point){};
PathMaker.prototype.path = function(thePath){};
PathMaker.prototype.add = function(point){};
PathMaker.prototype.addPath = function(path){};
PathMaker.prototype.go = function(distance, angle){};
PathMaker.prototype.goE = function(distance, angle){};
PathMaker.prototype.turn = function(angle, distance){};
PathMaker.prototype.continue = function(distance, a){};
PathMaker.prototype.curve = function(angle, radiusX, radiusY){};
PathMaker.prototype.up = PathMaker.prototype.north = function(distance){};
PathMaker.prototype.down = PathMaker.prototype.south = function(distance){};
PathMaker.prototype.east = function(distance){};
PathMaker.prototype.west = function(distance){};
PathMaker.prototype.getAngle = function(point){};
PathMaker.prototype.toBezierPoints = function(PathMakerPoints, toSource){};
PathMaker.prototype.extremities = function(points){};
PathMaker.prototype.bounds = function(path){};
PathMaker.prototype.tangent = function(t, points){};
PathMaker.prototype.roundErrors = function(n, acurracy){};
PathMaker.prototype.bezierTangent = function(path, t){};
PathMaker.prototype.splitBezier = function(points, t){};
PathMaker.prototype.arc = function(start, end){};
PathMaker.prototype.getKappa = function(angle, start){};
PathMaker.prototype.circle = function(radius, start, end, x, y, reverse){};
PathMaker.prototype.ellipse = function(radiusX, radiusY, start, end, x, y , reverse/*, anchorPoint, reverse*/ ){};
PathMaker.prototype.rotateArc = function(path /*array*/ , angle){};
PathMaker.prototype.rotatePoint = function(point, origin, r){};
PathMaker.prototype.roundErrors = function(n, acurracy){};
PathMaker.prototype.rotate = function(path /*object or array*/ , R){};
PathMaker.prototype.moveTo = function(path /*object or array*/ , x, y){};
PathMaker.prototype.scale = function(path, x, y /* number X scale i.e. 1.2 for 120% */ ){};
PathMaker.prototype.reverse = function(path){};
PathMaker.prototype.pathItemPath = function(pathItem, toSource){};
PathMaker.prototype.merge = function(path){};
PathMaker.prototype.draw = function(item, properties){};