Samples of Delphi App with MVC Pattern, used for educational purposes.
Please note: The examples are simplified and not complete.
A simple calculator without MVC pattern implementation.
A full-featured calculator application implementing the MVC pattern with both VCL and FireMonkey (FMX) support, demonstrating true cross-platform architecture.
- Standard Calculator: Basic arithmetic operations with a clean, modern interface
- Scientific Calculator: Extended with 6 scientific operations:
|x|- Absolute valuex³- Cubeexp- Exponential (e^x)x^y- Power (binary operation)10^x- Power of 10log- Base-10 logarithm
- Theme Selector (VCL only): Runtime enumeration and selection of VCL styles
- Font Selector (VCL only): System font selection with live preview
- Navigation Menu:
- VCL: TSplitView with TCategoryButtons for easy navigation
- FMX: TMultiView (Drawer mode) with TListBox for mobile-friendly navigation
- Settings Persistence: Theme and window position saved to .ini file
- Model-View-Controller Pattern: Clean separation of concerns
- Model: Pure business logic and mathematical operations (shared between VCL and FMX)
- View: Reusable frames implementing
ICalculatorViewinterface - Controller: Mediates between Model and View (shared between VCL and FMX)
- Frame-Based UI: Modular, reusable components for both VCL and FMX
- Shared Business Logic: Model and Controller units work with both UI frameworks
- Platform-Specific Views: Separate frame implementations for VCL and FMX
- Full Keyboard Support: Complete keyboard input for both calculators (VCL)
- Error Handling: Robust validation (division by zero, invalid logarithms, etc.)
- Unicode Symbols: Mathematical symbols for better visualization
Common (VCL & FMX):
- Frame switching with dynamic Controller management
- Separate Controllers for Standard and Scientific calculators
- GridPanel/GridLayout for responsive button grids
- Comprehensive XML documentation for educational purposes
VCL-Specific:
- TSplitView with overlay mode for slide-in menu
- TCategoryButtons with two categories (Calculator, Settings)
- VCL Actions for operation handling
- Intelligent keyboard input forwarding to active frame
FMX-Specific:
- TMultiView in Drawer mode for mobile-friendly navigation
- TListBox with custom styled items for menu
- Cross-platform compatibility (Windows, macOS, iOS, Android)
- Touch-friendly interface with larger buttons
- Responsive layouts using TGridLayout
Calculator_MVC/
├── Sources/
│ ├── Calculator.Types.pas (Shared - VCL & FMX)
│ ├── Calculator.Model.pas (Shared - VCL & FMX)
│ ├── Calculator.Controller.pas (Shared - VCL & FMX)
│ ├── Calculator.Resources.pas/dfm (Shared - VCL & FMX)
│ │
│ ├── Calculator.MainForm.pas/dfm (VCL Main Form)
│ ├── Calculator.CalculatorFrame.pas/dfm (VCL Standard Frame)
│ ├── Calculator.ScientificFrame.pas/dfm (VCL Scientific Frame)
│ ├── Calculator.ThemeFrame.pas/dfm (VCL Theme Selector)
│ ├── Calculator.FontFrame.pas/dfm (VCL Font Selector)
│ │
│ ├── Calculator.MainForm.FMX.pas/fmx (FMX Main Form)
│ ├── Calculator.CalculatorFrame.FMX.pas/fmx (FMX Standard Frame)
│ └── Calculator.ScientificFrame.FMX.pas/fmx (FMX Scientific Frame)
│
└── Projects/
├── Calculator.VCL.MVC.Project.dpr (VCL Windows Application)
└── Calculator.FMX.MVC.Project.dpr (FMX Cross-Platform Application)
- ~60% shared code: Model, Controller, and Types units work identically in both frameworks
- ~40% platform-specific: UI frames and main forms adapted for VCL/FMX
- Demonstrates best practices for maximizing code reuse in multi-platform Delphi applications
- MVC_Simple_Orders
- MVC_Orders_Customers
- MVC_Orders_Customers_IO
Demos and exercises for Delphi Day Seminar - Piacenza 16 June 2025
Copyright (c) 2025 (Ethea S.r.l.)
Author: Carlo Barazzetta
Contributors: Claude Code
Licensed under the Apache License, Version 2.0 (the "License");
