Doc/View Single Doc/Multiple View Help?
Doc/View Single Doc/Multiple View Help?
Hi all,
I am currently battling with my lack of knowledge as to the wxWidgets implementation of doc/view. Although T-Rex has a couple of good tutorials, I am still lost wrt single doc/ multiple view implementation.
Does anyone have a simple project that they could share which offers some insight into implementing this?
I understand the single doc/single view theory, but implementing a single doc/multiple view application isn't well documented.
I will be implementing at least 8 different (possible) views on a single document, so I need to understand a lot more about changes being reflected in other views, this I know, but I would be happy if I could understand how to implement the basic framework I need.
Hopefully someone has some code to share.
Many Thanks
Mal
I am currently battling with my lack of knowledge as to the wxWidgets implementation of doc/view. Although T-Rex has a couple of good tutorials, I am still lost wrt single doc/ multiple view implementation.
Does anyone have a simple project that they could share which offers some insight into implementing this?
I understand the single doc/single view theory, but implementing a single doc/multiple view application isn't well documented.
I will be implementing at least 8 different (possible) views on a single document, so I need to understand a lot more about changes being reflected in other views, this I know, but I would be happy if I could understand how to implement the basic framework I need.
Hopefully someone has some code to share.
Many Thanks
Mal
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
-
- I live to help wx-kind
- Posts: 196
- Joined: Tue Dec 07, 2004 8:54 pm
- Location: Essen, Germany
Hello NinjaNL,
I think the Observer pattern ( http://en.wikipedia.org/wiki/Observer_pattern ) is a good point to start your task implementation.
I think the Observer pattern ( http://en.wikipedia.org/wiki/Observer_pattern ) is a good point to start your task implementation.
-
- Knows some wx things
- Posts: 30
- Joined: Sun Dec 26, 2004 4:47 pm
- Location: Italy
I thought you couldn't implement a single doc/multiple view app with the doc/view framework, at least without heavily modify it. (I also started a thread some time ago: http://forums.wxwidgets.org/viewtopic.p ... t=doc+view) Am I wrong? Is it possible?
OS: Mac OS X ver 10.5 Compiler: gcc ver 4.0.1
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
You can, according to the book,nuvola_notturna wrote:I thought you couldn't implement a single doc/multiple view app with the doc/view framework
but this in one of those silly "I need to see it to understand it" things. Once I see some code I tend to have a "Duh" moment and then progress from there.For example, if there were two views of the data in a Doodle document—a graphical view and a list of segments—then we would create two view
classes (DoodleGraphicView and DoodleListView). We would also need two document templates, one for the graphical view and another for the list view. You would pass the same document class and default file extension to both document
templates, but each would be passed a different view class. When the user clicks on the Open menu item, the file selector is displayed with a list of possible file filters, one for each wxDocTemplate. Selecting the filter selects the
wxDocTemplate, and when a file is selected, that template will be used for creating a document and view. Similarly, when the user selects New, wxWidgets will offer a choice of templates if there is more than one. In our Doodle example,
where there is only one document type and one view type, a single document template is constructed, and dialogs will be appropriately simplified
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
-
- Knows some wx things
- Posts: 30
- Joined: Sun Dec 26, 2004 4:47 pm
- Location: Italy
mmh...sorry maybe I misunderstood your question (but I was somehow mislead by the observation about the observer pattern )...maybe we are talking about different things, I mean, what I would like to do is to have different views of the document which are active at the same time, while (I think) all you can do is to have the possibility to choose one among different views when you create the document; and this is actually quite simple (if you implemented the single view version) you just need to implement another view class and then pass both to the document manager. I tried this once. But in this way you can have just one view for your open document and you choose it when you open (or create) the document.
OS: Mac OS X ver 10.5 Compiler: gcc ver 4.0.1
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
As was I. I believe you understand me correctly.nuvola_notturna wrote:mmh...sorry maybe I misunderstood your question (but I was somehow mislead by the observation about the observer pattern )
I want to have several views of a single document.
Say a HTML file.
I would like to see 2 views
1) Pure Text (wxTextCtrl)
2) a simple HTML representation (wxHTMLWindow?)
When the user enters text in either, it should be reflected in both.
I suppose that it would be sensible to always open in a particular view (since it is in the example a html file, then it should open in view 2), but with the possibility of changing the view to view 1(pure text). It should also allow both views to be visible at the same time(?).
This should be possible using the current doc/view framework.
All of this is possible with the doc/view framework from wxArt2d, but I am convinced that something this simple should be realizable from a pure wxWidgets framework position.
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
-
- Knows some wx things
- Posts: 30
- Joined: Sun Dec 26, 2004 4:47 pm
- Location: Italy
Sincerely I also thought it should be possible! I mean, it's the first thing I thought about when I read about doc/view... but then I gave up, thinking it wasn't possible, also because I did not receive any answer here I think I will try again
If anyone has successfully tried I also would be very grateful to hear their experience.
If anyone has successfully tried I also would be very grateful to hear their experience.
OS: Mac OS X ver 10.5 Compiler: gcc ver 4.0.1
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
-
- Knows some wx things
- Posts: 30
- Joined: Sun Dec 26, 2004 4:47 pm
- Location: Italy
At the end, I decided to override wxDocManager::CreateDocument() in order to create a view per template, instead of choosing just one template and create the view for it.
If anyone has a better solution, it is very welcome
If anyone has a better solution, it is very welcome
OS: Mac OS X ver 10.5 Compiler: gcc ver 4.0.1
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
This problem (referring to the HTML paradigm NinjaNL mentioned) is not too difficult to solve but it requires a discipline to do it right.
You have the following:
What you need is to have is a mechanism that informs one or the other that something is changed.
For example, in the text editor at the moment a valid node is entered, you can parse this node and add it to the raw data tree. The tree in his context needs to inform the changed nodes, so that the HTML editor can update the view to reflect the changes.
It sounds like an observer pattern the problem I see is that the observer pattern tells the objects that are interested of states that change of objects. What if the objects are not yet created? You could pass a message along with the update call to tell a new object is created.
It is not an easy task but it is doable. The problems are confining the updates to a a restricted part of the document without having to result to redrawing every minor change which may result in sluggish behaviour of the system
- Jorgen
You have the following:
Code: Select all
HTML Editor --> Raw Data Tree <--- Text Editor
For example, in the text editor at the moment a valid node is entered, you can parse this node and add it to the raw data tree. The tree in his context needs to inform the changed nodes, so that the HTML editor can update the view to reflect the changes.
It sounds like an observer pattern the problem I see is that the observer pattern tells the objects that are interested of states that change of objects. What if the objects are not yet created? You could pass a message along with the update call to tell a new object is created.
It is not an easy task but it is doable. The problems are confining the updates to a a restricted part of the document without having to result to redrawing every minor change which may result in sluggish behaviour of the system
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Which I believed was a part of the Doc/View framework. Am I to understand that I was incorrect in my belief? (OK back to being agnostic)Jorg wrote:This problem (referring to the HTML paradigm NinjaNL mentioned) is not too difficult to solve but it requires a discipline to do it right.
You have the following:
What you need is to have is a mechanism that informs one or the other that something is changed.Code: Select all
HTML Editor --> Raw Data Tree <--- Text Editor
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/
-
- Knows some wx things
- Posts: 30
- Joined: Sun Dec 26, 2004 4:47 pm
- Location: Italy
to Jorgen: We were not really discussing about a pattern, instead we were wondering if we could use the doc/view framework provided by wxWidgets to solve this problem
OS: Mac OS X ver 10.5 Compiler: gcc ver 4.0.1
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
Windows: XP Professional x64 v 2003 SP2 Compiler: MinGW
wxWidgets 2.8.10 for All Platforms
...scusate non mi lego a questa schiera morrò pecora nera...
Ah sorry, the curse of lack of coffee and a wandering mind
- Jorgen
- Jorgen
Forensic Software Engineer
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb
Netherlands Forensic Insitute
http://english.forensischinstituut.nl/
-------------------------------------
Jorg's WasteBucket
http://www.xs4all.nl/~jorgb/wb