School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,452 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,584 people online right now. Registration is fast and FREE... Join Now!




General approach to building a WYSIWYG (not html) editor

 

General approach to building a WYSIWYG (not html) editor, What is the general approach to building a wysiwyg-editor that corresp

JLjungh

8 Jun, 2009 - 03:47 AM
Post #1

New D.I.C Head
*

Joined: 8 Jun, 2009
Posts: 2

Im doing some research on whats the general apporach to a WYSIWYG-editor.
The question i have been unable to find answer to is how to make the visualisation on your computer
monitor (the editor) correspond to what will eventually come out of the printer. The type of editor im
referring to is a Label editor in wich you can design labels, pricetags etc and later print them and the
output should look like what you saw on the screen when you designed it.

In printer terms you deal with points, inches, centimeters and so forth but when you draw to the
screen the common unit of measurement is pixels. How do you convert theese units?

Lets say you want to create a new Label with a width and height of 200 x 50 mm (on paper).
The visualisation of this on the screen should be a empty white rectangle with correct
proportions (4 to 1, width to height). In short, a empty document with correct proportions.

Since the unit of measurement on paper and the screen are not the same you have to do some sort of conversion.
So, how many pixels is 200 mm? Depending on the screen this can vary. dpi on screen etc.

Of course one can assume that the number of pixels per any given real-world measure unit most
of the time never be less than X and never more than Y since most computer monitors have a dot pich
of about ~0.28 mm.

So one solution is to simply do some arithmetical operation on the realworld (paper) size to get the size on screen.

Example. a rectangle is 200 mm wide and 50 high on paper. 1 mm on screen is about ~3,8 pixels so the width on the screen should be
about 200 x 3,8 = 760 and 50 x 3,8 = 190.

So the 1:1 representation on screen should be about 760 x 190 pixels. This would on most screens give a rectangle thats is roughly about 200 x 50 mm if you would pick up your ruler and measure directly on your screen.

So what do you think, whats the genereal approach on this matter? Is it ok to assume that most the users will have screen that will draw the rectangle roughly correct or is the another completely different approach i havent though of?

User is offlineProfile CardPM
+Quote Post


Oler1s

RE: General Approach To Building A WYSIWYG (not Html) Editor

8 Jun, 2009 - 05:21 AM
Post #2

D.I.C Addict
****

Joined: 4 Jun, 2009
Posts: 639



Thanked: 66 times
My Contributions
If this is something that needs to be to fed to a printer.

Start looking at postscript.
User is offlineProfile CardPM
+Quote Post

JLjungh

RE: General Approach To Building A WYSIWYG (not Html) Editor

8 Jun, 2009 - 06:27 AM
Post #3

New D.I.C Head
*

Joined: 8 Jun, 2009
Posts: 2

QUOTE(Oler1s @ 8 Jun, 2009 - 05:21 AM) *

If this is something that needs to be to fed to a printer.

Start looking at postscript.


Yes, this will eventually be sent to the printer. Buts that not what i was after. I got that part
covered. What i was looking for was a general technique/approach on how to visualize it
on the screen in a good way so what the user sees on the screen matches what will
eventually come out on the printer. In short, a WYSIWYG editor.

The user defines the dimensions of the objects, lets say a rectangle, in units of millimeters and centimeters.

The screen unit is pixels.

how do one determine the width in pixels on the screen given the width in centimeters or millimeters?
Is there a proven/established technique for this that software desigers use when building theese types
of applications?

This post has been edited by JLjungh: 8 Jun, 2009 - 06:28 AM
User is offlineProfile CardPM
+Quote Post

Oler1s

RE: General Approach To Building A WYSIWYG (not Html) Editor

9 Jun, 2009 - 08:31 AM
Post #4

D.I.C Addict
****

Joined: 4 Jun, 2009
Posts: 639



Thanked: 66 times
My Contributions
My mistake. I'll address your question first. The mapping of pixels to a unit of length is given by PPI. Related term is DPI. You definitely should know about both if you are making a WYSIWYG editor.

PPI and DPI are not fixed. Many applications assume they are however (to 96 PPI, I think), or don't properly address them. So sadly, other applications don't serve as good role models. Want to see how bad things get? Change the PPI on your computer. Watch things go horribly, horribly wrong in every GUI.

Getting the PPI of the display is OS specific, but it's possible. So do investigate for your respective OS. Before you run off gleefully knowing that you have metric to do pixel to length unit conversions, you should be warned of something else that you probably haven't considered.

You seem to be intelligently probing the issues in making an editor, so I apologize if once again I cover ground you already considered. If all you drew were lines and boxes on the screen, a WYSIWYG editor would not be so bad. You have to be mindful of PPI and DPI, and do a lot of math yourself, but it is doable.

Although APIs haven't exactly been considerate of PPI issues. Most of them will show you examples of how to specify GUI positioning by choosing pixel numbers directly. (Pixels directly? When the PPI can be different or changed?). In fact, I respect the Microsoft WPF designers and team for considering this issue. Even if you will not use WPF. You might be interested in how they addressed this mapping of device size. Measurements in WPF are done in device independent units! Although WPF has its own share of problems...

The problem is text. What is the size of the letter 'a'? This is dependent on so many factors. I only know enough about this to be dangerous. But if you're making something to create labels, pricetags, and so on, you will care about fonts and text, right? And that's where the problems start.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:53AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month