Hey, I'm working on a Paint program. I've never built a proper program before so I was wondering how I should go about structuring an actual piece of software. I'm trying to a make a simple paint application (like MS paint) using C++ and the SDL library.

Right now, I'm thinking along the lines of having two main objects, a Screen and a Handler. The Handler waits on the Screen class for events and processes the events and updates the Screen.

Something like this

class screen{} Screen;
class handler{
[INDENT]start(){
[INDENT]while(1){
[INDENT]drawscreen()
processevent()[/INDENT]
}[/INDENT]
}[/INDENT]
}

That looks very simple. Is this a scalable way of doing things? How I render things like lines and circles? Do I make a Line class and 'add' it to the screen, or just 'tell' the screen to draw a line? These are the kinds of questions I have. Any ideas?

a commonly used architecture is http://en.wikipedia.org/wiki/Model-view-controller

> Right now, I'm thinking along the lines of having two main objects, a Screen and a Handler
these roughly correspond to view and controller
lines, circles etc. would be part of the model.

Wow! Thanks!
Does this mean that things like toolbars would come under the Model or the View. For the actual drawing area, there's a model, thats fine. But for things like toolbars, is that a model or a view?

I was also wondering if storing all the drawing could be nicely done using XML?

> Does this mean that things like toolbars would come under the Model or the View
in general, *all* user interface elements (toolbars,statusbars,menu etc) would be part of the 'view'.

> I was also wondering if storing all the drawing could be nicely done using XML?
yes, that is the modern approach. (and the persistence/data access layer is encapsulated by the 'model'.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.