I derive my controller from Frame and put the events there. My view
creates a view given a wxDC. My events pass relevant information to the
model. The events also decide if it was such that the views need to be
updated. It also checks the model to see if the model thinks the views
need to be updated.
Conceptually, I have the controllers separate from the models separate
from the views.
Ralph
al_lo_ja wrote:
>
> Hello,
>
> I want a clear separation between the UI and the business logic.
>
> How do you achieve this? How do you organize your source files for
> your applications? Which folders do you generally create?
>
> I have tried this for my first wxWidget application:
> \main.cpp
> \MyApp.h
> \MyApp.cpp
> \Controllers\MyAppController.h
> \Controllers\MyAppController.cpp
> \Models\MyAppModel.h
> \Models\MyAppModel.cpp
> \Views\MyMainWindow.h
> \Views\MyMainWindow.cpp
>
> - main.cpp contains only DECLARE_APP(MyApp) and IMPLEMENT_APP(MyApp)
> - the MyApp class inherits from wxApp. MyApp.cpp contains the OnInit
> method and creates a MyAppController object
> - the MyAppController object creates a MyAppModel object and a
> MyMainWindow object
> - MyAppModel is the core of the application and knows nothing about
> the GUI
> - MyMainWindow inherits from wxFrame and is the main window of the
> application
>
> As you can see I've been trying to implement the MVC
> (model/view/controller) pattern. But I don't know where's the best
> place to put the event handlers.
>
> How do you organize your source files? Where do you catch events?
>
> Kind regards,
> Al
>
>