I have heard that somewhere # web I'll be able to find good C++ example of Mediator working with GUI components. But I menaged to find only that GoF sample or things from sorcemaking and similar that aren't helpful to me.
So... do you know where that mentioned GUI sample can be found?
Sorry for that kind of question, but that can be useful for others too.
How about this one: http://www.andypatterns.com/index.php/design_patterns/model_gui_mediator_pattern/. It appears the author is applying the pattern specifically to the 'view' part of the GUI functionality (as opposed to the data modeling behind it).
Not sure if that's what you were looking for...
Related
I'm creating one tab based C++ application using GTK+ toolkit and Webkit for learning purpose. I've created following files
Main.cpp => Application entry-point
MainWindow.cpp/.h => MainWindow which creates toolbar object, Notebook, Statusbar
Toolbar.cpp/.h => toolbar items like back, forward, urlbar, stop/refresh,
NotebookContainer.cpp/.h => for creating new tab etc
TabWebView.cpp/.h => for creating tab(label+close button), web-view etc.
Now I want to communicate in between toolbar and TabView class. So when any event occur on toolbar I can do the action in webview.cpp and some event trigger from webview I can do the required on toolbar (like enabling/disabling stop button)
Which design pattern should I need to follow in this scenario?
NOTE: GTK+ is c based library.
I would like to suggest that you are asking the wrong question. Rather than asking what design pattern to follow, I would suggest you ask what the most idiomatic way to solve your problem is.
All too often the wors design failures I have to fix come from a young coder whose approach is "what design pattern can I use here?", or "How can I use more design patterns".
Studying design patterns is useful in providing a vocabulary for discussing your designs, and they are useful in inspiring and informing your design choices, but your design approach should always be "what the simplest, cleanest, most effective, idiomatic approach here". Sometimes the answer to that question will be a design pattern. Sometimes it will a part of a design pattern, and sometimes it will be something much simpler -- typically an idiom in the language or library you are working with.
I don't do a lot of GUI programming, so I can't help much with your concrete question. For the problem you are presenting, it sounds like you want to use GTK's signal/slot framework. Alternatively boost offers similar functionality if you want to get familiar with boost's tools. Both would be idiomatic approaches to what you want to do.
I think what you are looking for is some along the lines of an observer pattern:
http://sourcemaking.com/design_patterns/observer
and more generally something like Model-View-Controller or Presentation-Abstraction-Control models:
http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
http://en.wikipedia.org/wiki/Presentation%E2%80%93abstraction%E2%80%93control
You might want to have a look at the Qt Signal/Slot implementation also:
http://qt-project.org/doc/qt-4.8/signalsandslots.html
I was looking at MeVisLab and I wondered if anyone knows a good framework for making a user interface similar to the one they use. I like the designing flow with boxes and arrows thing.
What I would really like is to able to integrate with C++ using Qt, and perhaps export the graph to xml of something like that.
There is another example of the interface here:
I hope someone knows something
Qt's Graphics View is a "framework" which does a good bit of the handling for the kind of scenario you describe. It doesn't take much code to get off the ground and within striking range of what you're looking for:
http://doc.qt.nokia.com/latest/graphicsview-diagramscene.html
http://doc.qt.nokia.com/latest/graphicsview-elasticnodes.html
I'm not aware of any open-source Qt-based programs that offer exactly what you want already written. Just noticed IBM did open source "DataExplorer", which is interesting to me...I might go take a look at that myself:
http://www.research.ibm.com/dx/
I have two apps that need to receive notifications when data in a table changes. One .NET and the other C++ MFC. I decided to go with SQL Query Notifications.
I have built a proof of concept for the .NET app with SqlDependency class, but am struggling with the MFC version.
I found this http://msdn.microsoft.com/en-us/library/ms130764.aspx, but am not proficient enough with c++ to make sense of this.
Has anyone done this before? If so, could you please post some sample code or point me in the right direction?
Thanks in Advance
I can't see example code for C++ anywhere.
Rather than write and debug this (complex) event detection code twice, it would be possible (and preferable imo) to implement it in C#, and then expose the required function to your MFC app via COM interop. See here for a brief overview.
I would like to start coding a gtk theme engine, but i'm wondering where i can find some documentation, if any exists.
I know how to have look at someone else engine's code, examples, or torture tests and widget factories etc.., what i want instead is any documentation type, design, references, examples or tutorials possibly from reliable sources such as the Gnome foundation or the like.
You know, when coding for the Win32 platform one can pinpoint reliable references on the subject by following the MSDN and then read a variety of other sources to see how the problem has been tackled, if any.
So, where to find an authoritative, reliable and possibly complete source of documentation about GTK theme engine development? Is there any for real?
Later added:
Also, how to debug such an engine? What's the most sane and painless way to perform testing and debugging on such a delicate os' ui component?
Well, you can look for instance at the source for the gtk smooth engine in Ubuntu most of which is in one fairly enormous C file smooth_gtk2_drawing.c. I don't know if that's an especially good example, but probably finding whichever looks simplest or most actively maintained would be a good idea.
A theme engine is typically used to change the shape of widgets among other things. If you're just trying to change the color scheme and so on, you just need to create a theme.
Just like the theme engines, theres not a whole lot of documentation when it comes to creating a theme either. However, there are a ton of examples at http://www.gnome-look.org
So I understand that there are a few options available as far as parsing straight XML goes: NSXMLParser, TouchXML from TouchCode, etc. That's all fine, and seems to work fine for me.
The real problem here is that there are dozens of small variations in RSS feeds (and Atom feeds too), so supporting all possible permutations of feeds available out on the Internet gets very difficult to manage. I searched around for a library that would handle all of these low-level details for me, but came out without anything.
Since one could link to an external C/C++ library in Objective-C, I was wondering if there is a library out there that would be best suited for this task? Someone must have already created something like this, it's just difficult to find the "right" option from the thousands of results in Google.
Anyway, what's the best way to parse RSS/Atom feeds in an iPhone application?
I've just released an open source RSS/Atom Parser for iPhone and hopefully it might be of some use.
I'd love to hear your thoughts on it too!
"Best" is relative. The best performance you'll need to go the SAX route and implement the handlers. I don't know of anything out there open source available (start a google code project and release it for the rest of us to use!)
Whatever you do, it's probably a really bad idea to try and load the whole XML file into memory and act on it like a DOM. Chances are you'll get feeds that are much larger than you can handle on the device leading to frequent memory warnings and crashes.
I'm currently trying out the MWFeedParser #Michael Waterfall is developing.
Quite easy to set up and use (I'm a beginner iPhone developer).
His sample code for using MWFeedParser to populate a UITableViewController implementation is helpful as well.
take a look at apple's XML Performance sample -- which points to using libXML directly -- for performance and quicker updates to the display. Which may be important if you are working with very large feeds.
Check out my library for parsing Atom feeds, (BSAtomParser) at GitHub. It doesn't care about validating the feed, it does its best at returning whatever is valid. The parser covers most of RFC 4287, even extensions.
Here's my solution: a really simple yet powerful RSS parsing library: https://github.com/H2CO3/RSSKit
Have you looked at TouchCode yet? I don't think it has an RSS processor, but it might give you a start.
http://code.google.com/p/touchcode/
I came accross igasus project on sourceforge today. I haven't used it or really checked it, but perhaps it might help.
From their site:
igagus is a web service for the iPhone that allows aggregation of RSS to be delivered in an iPhone friendly format.
Actually, I was trying to suggest you ask on the TouchCode discussion board, because I remember someone was trying to expand it to support RSS. That might be a decent starting point. But I was being rushed by my wife.
But I see now that TouchCode doesn't have a discussion board. I'd still ask the author, though, he might know what came of that effort.
This might be a reasonable starting point for you. Atom support isn't there yet, but you could help out?