GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Mar-2006, 19:45
SilasX SilasX is offline
New Member
 
Join Date: Mar 2006
Posts: 12
SilasX will become famous soon enough

Intro to programming word processors?


Hello all, found this forum through Google, and I was hoping one of you could help. Basically, I want to learn the basics of programming word processors in C++. Specifically, these are the things I want to learn how to do:

1) Have a window in which you can type text.

2) Make some of the text bold, italics, underlined, etc.

3) Implement an algorithm for saving the document, and read it back in.

4) Make the things it saves have a special extension such that if I open such a document, it will load through my word processor program.

I know there are open source word processor programs I can study, but I don't even know where to begin in terms of what files and parts of files I need to go to see what gets implemented where.

Any suggestions about where I should go?
  #2  
Old 11-Mar-2006, 21:45
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,498
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Intro to programming word processors?


This is NOT a discouragement, but just my "2 cents"...

To me, this would seem to somewhat be a waste of time. Yes, you may learn some of the programming aspects you mention, but why "re-invent the wheel", so to speak?

There are already many, many word processors (and/or editors) available. You could refer to several open-source type applications and see what they already do for the things you ask about and you'll have a head start on what is already done -- heck, you may find a better way to do some of those things should you still decide to create one.
  #3  
Old 11-Mar-2006, 22:55
SilasX SilasX is offline
New Member
 
Join Date: Mar 2006
Posts: 12
SilasX will become famous soon enough

Re: Intro to programming word processors?


Quote:
Originally Posted by TurboPT
This is NOT a discouragement, but just my "2 cents"...

To me, this would seem to somewhat be a waste of time. Yes, you may learn some of the programming aspects you mention, but why "re-invent the wheel", so to speak?

There are already many, many word processors (and/or editors) available. You could refer to several open-source type applications and see what they already do for the things you ask about and you'll have a head start on what is already done -- heck, you may find a better way to do some of those things should you still decide to create one.

I appreciate your concern, but I am aware of all of this, seriously. The problem is that no word processor does the task I need it to. In order to program one, I need to learn the rudiments of programming one. Even if want to springboard from an existing open source one, and God knows I've tried, it won't help much unless I can make heads or tails of *anything* in the source code. So I need to get my feet wet before I can hope to understand one. Now do you see why I'm asking?
  #4  
Old 12-Mar-2006, 00:11
TurboPT's Avatar
TurboPT TurboPT is offline
Senior Member
 
Join Date: Feb 2006
Location: Atlanta, GA
Posts: 1,498
TurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the roughTurboPT is a jewel in the rough

Re: Intro to programming word processors?


Yes, I understand, but what kinds of operations/features do you need that:

Quote:
...no other word processor does...
?

I know that 'features' of certain word processors are scattered across many, and usually not ALL the features one would like are not in a more likable app, therefore one usually finds one that SEEMS most useful and which has most of the features that we may like.

I don't know what development environment you have (or plan on using), but if you have Visual C++ 6, I know that through the 'new projects', the 'MFC AppWizard' [a 6-step wizard] has a Multiple Document Interface (MDI) [an MS Word like interface] option that can at least give you a jump on the basics of the items in your first post (except #2, but basic printing support is added -- if you don't uncheck the option! Plus, in step 4, the 'advanced' button is where you can specify your file extension(s)).

You can then look through the code (which is not as much as you may think, less than 600 lines total across 5 generated .cpp files) after creation to see where/how it added your choice(s). Heck, with the basic wizard's skeleton, you can set breakpoints and step through certain areas of the app as it runs to see what happens underneath.

Unless, that is, you want to start more basic than this (or just don't have Visual C++). I know Borland had a similar wizard too. I don't mind lending help if I can, or I'll at least provide pointers to other information. I'm sure others will respond too.
__________________
Use the force...read the source!!
WYCIWYG -- what you code is what you get!
Last edited by TurboPT : 12-Mar-2006 at 01:14.
  #5  
Old 12-Mar-2006, 09:25
davis
 
Posts: n/a

Re: Intro to programming word processors?


Quote:
Originally Posted by SilasX
Hello all, found this forum through Google, and I was hoping one of you could help. Basically, I want to learn the basics of programming word processors in C++.

You haven't given us any indication of your current C++ programming skills and you probably should give us an idea of what platform(s) you intend to target.

Quote:
Originally Posted by SilasX
Specifically, these are the things I want to learn how to do:

1) Have a window in which you can type text.

I guess by "window" you mean a GUI. We still need the platform(s).

Quote:
Originally Posted by SilasX
2) Make some of the text bold, italics, underlined, etc.

This opens up a Pandora's box of issues. Are you going to use resizeable "fonts?" Do you need to support internationalized character sets (UNICODE)? We should probably assume that you want it to be WYSIWYG?

Quote:
Originally Posted by SilasX
3) Implement an algorithm for saving the document, and read it back in.

This could be very simple, but more likely will be very complex. Will your WP support embedded document types such as tables, graphs, images, etc.? What of document properties such as margins, text columns, text wrapping around embedded images, headers, footers, footnotes, etc.etc.etc.?

Quote:
Originally Posted by SilasX
4) Make the things it saves have a special extension such that if I open such a document, it will load through my word processor program.

Again, this is platform-specific. When you say "open" you do not mean open while interfacing a "menu" in your WP, rather, you mean that if you click on a file inside of some kind of graphical directory and file viewer, that you can invoke your WP and cause it to open the related file based on the file extension. As you can imagine, this is highly platform dependent.

Quote:
Originally Posted by SilasX
I know there are open source word processor programs I can study, but I don't even know where to begin in terms of what files and parts of files I need to go to see what gets implemented where.

...and that, in a nutshell, is the complexity of a modern, graphical word processing package. Even without a bunch of bloated bells and whistles, just the few things that you've mentioned are relatively complex to implement even if just targeting a single platform.

Quote:
Originally Posted by SilasX
Any suggestions about where I should go?

Without knowing the platform(s), there isn't much that I can do but to say go to trolltech.com and download Qt for your platform. Use Qt designer and implement your basic application elements such as the main window, menu, toolbar buttons and document windows. Qt 4.x supports MVC (model, view, controller) so that you'll have a good starting point for doing what you seek. You can begin with a QTextEdit class and add to it by deriving your own QTextEdit and/or QTextDocument. It is about the easiest possible way to get started writing your own graphical, WYSIWYG word processor in C++...that can also target several platforms including Windows, UNIX and Mac.


:davis:
  #6  
Old 12-Mar-2006, 11:31
SilasX SilasX is offline
New Member
 
Join Date: Mar 2006
Posts: 12
SilasX will become famous soon enough

Re: Intro to programming word processors?


Quote:
Originally Posted by TurboPTI don't know what development environment you have (or plan on using), but if you have Visual C++ 6, I know that through the 'new projects', the 'MFC AppWizard' [a 6-step wizard
has a Multiple Document Interface (MDI) [an MS Word like interface] option that can at least give you a jump on the basics of the items in your first post (except #2, but basic printing support is added -- if you don't uncheck the option! Plus, in step 4, the 'advanced' button is where you can specify your file extension(s)).

You can then look through the code (which is not as much as you may think, less than 600 lines total across 5 generated .cpp files) after creation to see where/how it added your choice(s). Heck, with the basic wizard's skeleton, you can set breakpoints and step through certain areas of the app as it runs to see what happens underneath.

Unless, that is, you want to start more basic than this (or just don't have Visual C++). I know Borland had a similar wizard too. I don't mind lending help if I can, or I'll at least provide pointers to other information. I'm sure others will respond too.

You're right, I should have specified the platform. Thankfully, I'm working with VC++ 6. (And double thankfully that people still use it!) What you've explained has been very helpful. Though I still need to know how to have a text input window and make style changes. Someone on another forum gave me the source for one of the versions of WordPad, which should help.

Quote:
Originally Posted by TurboPT
Yes, I understand, but what kinds of operations/features do you need that:

?

I know that 'features' of certain word processors are scattered across many, and usually not ALL the features one would like are not in a more likable app, therefore one usually finds one that SEEMS most useful and which has most of the features that we may like.

Just for reference, I've had a history of people lecturing me that such word processors exist, then after a few days of re-explaining the feature, they admit it really doesn't. Here's what the final version should have:

1) I should be able to define xml tags that can make style changes to the enclosed text (some combination of font change, size change, bold, italics, underline, etc.). Okay, so far, probably a solution out there.

2) I should be able to draw arrows between phrases within the text, and the data about which arrow points to what should be stored in xml tags.

3) I should be able to make change either in the WYSIWIG view or in the "source" view.

4) I should be able to give super- and sub-scripts to entire phrases, indicate what phrase the script refers to, and store this information in a tag rather than as text.

5) I should be able to view just the plain text of the document without any style changes or markup just by going to a different tab or clicking a button.

6) I should be able to apply or remove tags by highlighting and right-clicking the appropriate phrase.

7) When another option is selected, highlight/right-click should bring up a menu, populated from a database accessed based on the highlighted portion, and then apply a tag based on the menu selection.

8 ) I should be able to create multiple sets of rules that I can tell it to use to run through the file and add certain tags (with options) to specific words or phrases.
  #7  
Old 12-Mar-2006, 11:34
SilasX SilasX is offline
New Member
 
Join Date: Mar 2006
Posts: 12
SilasX will become famous soon enough

Re: Intro to programming word processors?


Quote:
Originally Posted by davis
Without knowing the platform(s), there isn't much that I can do but to say go to trolltech.com and download Qt for your platform. Use Qt designer and implement your basic application elements such as the main window, menu, toolbar buttons and document windows. Qt 4.x supports MVC (model, view, controller) so that you'll have a good starting point for doing what you seek. You can begin with a QTextEdit class and add to it by deriving your own QTextEdit and/or QTextDocument. It is about the easiest possible way to get started writing your own graphical, WYSIWYG word processor in C++...that can also target several platforms including Windows, UNIX and Mac.

Thank you for pointing me to this.
  #8  
Old 12-Mar-2006, 19:08
QED's Avatar
QED QED is offline
Member
 
Join Date: Feb 2005
Location: Hudson Valley, NY
Posts: 231
QED is a jewel in the roughQED is a jewel in the roughQED is a jewel in the rough

Re: Intro to programming word processors?


I too recommend against reinventing the wheel, but you make a good case regarding your need for features that may not currently exist in well-known word processors.

Why not compromise? Start with an open source word processor such as OpenOfficeWriter or Abiword (to name two that are available for Windows platform), and modify it to add the features you need that it lacks. That is one of the primary goals behind Free Software, that the user is free to change it to suit his or her needs.

Along the way you'll learn a lot by examining the (hopefully) well-written code that others have spent a great deal of time on.

Matthew
  #9  
Old 12-Mar-2006, 21:31
davis
 
Posts: n/a

Re: Intro to programming word processors?


Quote:
Originally Posted by QED
I too recommend against reinventing the wheel, but you make a good case regarding your need for features that may not currently exist in well-known word processors.

Why not compromise? Start with an open source word processor such as OpenOfficeWriter or Abiword (to name two that are available for Windows platform), and modify it to add the features you need that it lacks. That is one of the primary goals behind Free Software, that the user is free to change it to suit his or her needs.

Along the way you'll learn a lot by examining the (hopefully) well-written code that others have spent a great deal of time on.

Matthew

It is easy to recommend the advanced code-bases of OOWriter and such, but I think that:

Quote:
Originally Posted by SilasX
I know there are open source word processor programs I can study, but I don't even know where to begin in terms of what files and parts of files I need to go to see what gets implemented where.

...doesn't sound like traipsing around in the "complex" world of multi-platform code bases is going to solve the questions at hand. However, it is possible that the exploration of the code complexities of a robust word processor exceeds the skills of someone looking for an alternative. Obviously, a few hacks to add the features needed would be easier with a comfort level of the software base. Better it is, I think, that we point in a direction of least resistance and let the natural outcome of such perseverance tend to itself?

I'd probably recommend VBA, and making mods to "werd" ...but I can't make myself!


:davis:
  #10  
Old 12-Mar-2006, 21:36
SilasX SilasX is offline
New Member
 
Join Date: Mar 2006
Posts: 12
SilasX will become famous soon enough

Re: Intro to programming word processors?


Quote:
Originally Posted by QED
I too recommend against reinventing the wheel, but you make a good case regarding your need for features that may not currently exist in well-known word processors.

Why not compromise? Start with an open source word processor such as OpenOfficeWriter or Abiword (to name two that are available for Windows platform), and modify it to add the features you need that it lacks. That is one of the primary goals behind Free Software, that the user is free to change it to suit his or her needs.

Along the way you'll learn a lot by examining the (hopefully) well-written code that others have spent a great deal of time on.

That's how I thought it would work, but I about fainted when I tried to delve into the source code for OOo and even simpler word processors. I just haven't worked with anything like that before, so I wanted to get an understanding of the fundamentals before I tried to modify a really big program. I mean, once I learned how to do a console for a graphical game, but nothing involving text style changes or that sort of thing.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
printer / font color / windows programming nicolas_qc MS Visual C++ / MFC Forum 0 04-Jan-2006 00:13
Finding a word in a 2d grid The_Kingpin C Programming Language 4 24-Feb-2005 20:53
justifying text with dynamic programming twigboy C++ Forum 6 03-Feb-2005 15:30
GUI programming crystalattice C++ Forum 5 14-Sep-2004 12:17

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 10:39.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.