wxWidgets video player - c++

I want to play a video in a frame using wxSmith ( which is a wxWidgets extension ) . I've read the documentation from their website ( http://docs.wxwidgets.org/2.6.3/wx_wxmediactrl.html ) but I barely understood it . What I did by now :
wxMediaCtrl* Video;
wxString filename='/home/cristi/Desktop/intro.mp4';
Video= new wxMediaCtrl(this, filename,"IDVideo",wxDefaultPosition,wxDefaultSize,0,wxT(""),wxDefaultValidator,wxPanelNameStr);
this->Connect(IDVideo, wxEVT_MEDIA_STOP, (wxObjectEventFunction)
(wxEventFunction)(wxMediaEventFunction) &t2Frame::OnMediaStop);
void t2Frame::OnMediaStop(const wxMediaEvent& evt)
{
if(I don't know what to put here)
{
m_mediactrl->SetPosition(
m_mediactrl->GetDuration() << 1
);
evt.Veto();
}
}
But I don't know what to do next. I have a lots of error. It's the first time I use wxWidgets and I've searched a lot on the Internet but no results.
Thanks in advance.

Two general advices:
Start from a non-ancient wxWidgets version such as 3.0.2.
Look at the sample showing the use of this control.
Beyond this I really am not sure what are you asking about, e.g. why are you handling wxEVT_MEDIA_STOP in the first place. And, of course, you should really make some better effort than "lots of error[s]" if you want to get any help.

Related

Replacement for QTextCodec::setCodecforCStrings in Qt5

I have a lot of legacy that was making use of QTextCodec::setCodecForCStrings to handle other languages such as portuguese, swedish and italian. I know of this solution:
QTextCodec::setCodecForCStrings is GONE in Qt5
And have also read that blog
http://www.macieira.org/blog/2012/05/source-code-must-be-utf-8-and-qstring-wants-it/
but it does not help at all. The fact that this function is gone really is a dealbreaker for me.
I have considered writing my own QString class or copying the source code for SetCodecForCStrings and adapting it for Qt5. I will deal with cross-platform issues (it was already dealt with anyway).
Has anyone tried this ? If so what problem did you encounter ? Is there anything already made that could be used instead (library, wrapper, adapter) ? I do not mind paying for it if I need to. Or maybe I just have to stick with qt4 but I really like the new connect syntax...
Edit :
int main(int argv, char** args)
{
// Create test application.
QApplication application(argv, args);
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB18030-0"));
//My main form shown here
return application.exec();
}

Add accelerator ctrl+F for text search

I am trying to add a Ctrl+F accelerator to my gtkmm textview program. I already implemented the search function into an gtk Entry field, so the only thing I need is to get focus the find entry when Ctrl+F is pressed.
I googled and checked tutorials/reference of gtkmm (2.4, I'm working with that) but the only things I found were accelerators in context with menus and toolbars using UIManager, which I don't have in that .cc file I use (and I can't add them, cause its an existing program).
I tried to add an action with an AccelKey on a button or tried the function add_accelerator() but I wasn't able to use them properly (I am pretty new to gtkmm and there aren't enough samples - at least none I understand). Here some examples I tried:
_gtkActionGroup->add(
Gtk::Action::create("find", "Find", "search in file"),
Gtk::AccelKey("<control>F"),
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
I didn't know how to add this action to the button (in the toolbar) I created...
_gtkAccelGroup(Gtk::AccelGroup::create()) //initialized in the constructor of the class
...
_gtkBtnFind.add_accelerator("find", _gtkAccelGroup, GDK_Find,
Gdk::ModifierType::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
I tried here something, but I didn't really understand neither the parameters I needed to enter here nor how this method works - ofc it didn't work...
I'd be really happy if anyone can explain me how this things work properly and sorry for my bad english. If there are any things you need just tell me please. Thanks in advance
Greetings
edit: I looked up in the gtk sources and tried to understand the parameters of add_accelerator. Now I tried this but still doesn't work...:
_gtkBtnFind.add_accelerator("clicked", _gtkAccelGroup, GDK_KEY_F /* or better GDK_KEY_f ?*/,
Gdk::ModifierType(GDK_CONTROL_MASK), Gtk::AccelFlags(GTK_ACCEL_VISIBLE));
_gtkBtnFind.signal_clicked().connect(
sigc::mem_fun(this, &SrcFilesView::onGtkTxtFindAccKeyPressed));
UPDATE:
Okay I have understood most I think now, and I know why it doesn't work. The problem is that I have to add the accel_group to the window widget, but I got only a scrolled window and boxes in my program....and now I have no clue how to continue... :)
UPDATE2:
Alright I managed to do it without accelerators by using the "on_key_press_event" handler by checking the state and keyval parameter. Hope this helps some ppl at least ^^.
bool on_key_press_event(GdkEventKey* event) { /* declaration in my constructor removed */
if(event->state == GDK_CONTROL_MASK && event->keyval == GDK_KEY_f
|| event->state == (GDK_CONTROL_MASK | GDK_LOCK_MASK)
&& event->keyval == GDK_KEY_F) {
_gtkEntFind.grab_focus();
}
return false;
}
I would be still interested in a solution with the accelerators if there is any ! Greetings

DarkGDK changing display mode makes sprites dissapear

After executing the application, user clicks the start button. At the time I want to change the display to different dimensions. But doing that the screen becomes black and images doesn't paste.
while ( LoopGDK ( ) )
{
if(dbMouseClick()==1){
int x=dbMouseX(), y=dbMouseY();
if(x>370 && x<498 && y>240 && y<368){
dbDeleteImage(1);
dbDeleteImage(2);
bg_exist=false;
}
}
if(!dbSpriteExist(1)&&bg_exist==false){
dbSetDisplayMode(800,224,32);
dbPasteImage(3,0,0);
}
dbSprite(2,370,240,2);
dbPasteImage(1,0,0);
dbSync ( );
}
This engine is outdated and almost not used by any one anymore.
There are plenty way better engines out there, full list can be found here
My favourite would be unreal engine
I would suggest to play around with unreal engine since it has way better support and more easy to use features.

wxPython - how to colour the text of a statusbar

I searched for the answer in the forum, but I didn't find anything, if I am wrong, I am sorry.
Anyway, question is simple, I have this Frame, with a Status Bar I use to print messages or notifies.
I would like to use it for mistakes or not permitted operations. But I would like these messages to be coloured. I am looking for a solution on wxPython demo -because i read somewhere on the web to get some inspirations by it-, but i still did not find anything.
Do you have any ideas or solutions?
thank you in advance.
I would try the SetForegroundColour or SetBackgroundColour methods of the status bar widget. These methods don't always work on every platform though as each OS has its own rules and wxPython follows those rules. If they do not work, then you'll have to roll your own statusbar, probably by using a couple of panels in a sizer or a splitter window.
There is also the 3rd party EnhancedStatusbar widget which might work for you. It can be found at http://xoomer.virgilio.it/infinity77/main/EnhancedStatusBar.html
Simple solution: pin wx.StaticText on the status bar and write text in it. Text coloring in wx.StaticText works well.
For example:
self.sb = self.ws.CreateStatusBar()
self.sbtext = wx.StaticText(self.sb, -1, '', pos=(8, 4))
...
self.sbtext.SetForegroundColour(wx.Colour(color))
self.sbtext.SetLabel(text)

C++ Flowchart / GUI Designer

I need to write a C++ GUI such that user can make a flowchart / pipeline by selecting several blocks from a toolbar and putting them into a window and connecting them in some order which he wants and then program runs the flowchart. (For simplicity just consider each block's task is to print some number. My problem is GUI)
Does anyone ever try a similar thing / any experience?
Is it possible to make such a GUI in WxWidget or any other Graphics/Window-form library?
Is it possible to use VTK to make the GUI?
Do you know of any similar open source work?
I have developed several apps with GUIs that do this sort of thing.
The one I am most pleased with is called VASE: A GUI used to create the layout, set parameters and view results of a process flow simulator.
It is not a trivial task, though once you have done one or two, there are many ideas that you can reuse and it goes quickly.
The two biggest challenges drawing the lines connecting the objects ( as you can see, even in VASE, this problem is not completely solved ) and storing that layout in a format that can be easily recovered and redrawn.
Is there any particular issue you need help with?
If you want a really, really, simple example to get you started I have re-implemented a couple of basic features ( all nice and clean, no copyright restrictions ) - left click to select, drag to move, right click to connect.
Here is the source code repository - http://66.199.140.183/cgi-bin/vase.cgi/home
Here's what it looks like
I have implemented a simplified connector, which I call a pipe. To give you a flavour of how to do this kind of stuff, here is the code to add a pipe when the user right clicks
/**
User has right clicked
If he right clicks on a flower
and there is a different flower selected
then connect the selected flower to the right clicked flower
if he right clicks on empty background
create a new flower
*/
void cVase::MouseRightDown( wxMouseEvent& event )
{
// find flower under click
iterator iter_flower_clicked = find( event.GetPosition() );
// check there was a flower under click
if( iter_flower_clicked != end() ) {
// check that we have a selected flower
if( ! mySelected )
return;
// check that selected flower is different from one clicked
if( mySelected == (*iter_flower_clicked) )
return;
// construct pipe from selected flower to clicked flower
myPipe.push_back(cPipe( mySelected, *iter_flower_clicked ));
} else {
// no flower under click
// make one appear!
cFlower * pflower = Add();
pflower->setLocation( event.GetPosition() );
}
// redraw everything
Refresh();
}
And here is the code to draw a pipe
/**
Draw the pipe
From starting flower's exit port to ending flower's entry port
*/
void cPipe::Paint( wxPaintDC& dc )
{
dc.SetPen( *wxBLUE_PEN );
dc.DrawLine( myStart->getExitPort(), myEnd->getEntryPort() );
}
You can see the rest of the wxWidgets code that ties all this together by browsing the source code repository.
I think using a library such as wxArt2D would be easier than using the standard wxWidgets drawing classes. The wires sample of wxArt2D looks similar to what you are looking for.
Maybe you can have a try with the tiny tool called Flowchart to Code, you can get the flowchart needed,like this. It can be downloaded here:http://www.athtek.com/flowchart-to-code.html#.Ug4z29JPTfI