Overview
TheCalculatorManager class is the primary interface for interacting with the Windows Calculator calculation engine. It manages multiple calculator modes (Standard, Scientific, Programmer), memory operations, history, and display callbacks.
Constructor
Callback interface for display updates and notifications
Provider for localized strings and resources
Example
Calculator Modes
SetStandardMode()
Switches to Standard calculator mode with basic arithmetic operations.- Sets precision to 16 digits (StandardModePrecision)
- Disables order of operations precedence
- Resets to decimal radix
- Uses standard history
SetScientificMode()
Switches to Scientific calculator mode with advanced mathematical functions.- Sets precision to 32 digits (ScientificModePrecision)
- Enables order of operations precedence
- Supports trigonometric, logarithmic, and exponential functions
- Uses scientific history
SetProgrammerMode()
Switches to Programmer calculator mode with bitwise operations and multiple bases.- Sets precision to 64 bits (ProgrammerModePrecision)
- Enables integer-only mode
- Supports Hex, Decimal, Octal, and Binary radix
- Disables history
Command Processing
SendCommand()
Sends a command to the calculator engine for processing.The command to execute (arithmetic operation, function, mode change, etc.)
Example
Memory Operations
MemorizeNumber()
Stores the current displayed value in memory.- Inserts value at the beginning of the memory list
- Maximum memory size is 100 items
- Ignored if calculator is in error state
MemorizedNumberLoad()
Recalls a memorized number to the primary display.Zero-based index of the memory item to recall
MemorizedNumberAdd()
Adds the current display value to a memorized number.Zero-based index of the memory item to modify
- If memory is empty, creates new memory item with current value
- Notifies display callback of memory change
MemorizedNumberSubtract()
Subtracts the current display value from a memorized number.Zero-based index of the memory item to modify
MemorizedNumberClear()
Removes a specific memory item.Zero-based index of the memory item to remove
MemorizedNumberClearAll()
Clears all memorized numbers.History Management
GetHistoryItems()
Retrieves history items for the current mode.Reference to vector of history items
GetHistoryItems(mode)
Retrieves history items for a specific calculator mode.The calculator mode (Standard or Scientific)
SetHistoryItems()
Restores history items (used for persistence).Vector of history items to restore
GetHistoryItem()
Retrieves a specific history item by index.Zero-based index of the history item
RemoveHistoryItem()
Removes a history item by index.Zero-based index of the history item to remove
True if item was removed, false otherwise
ClearHistory()
Clears all history for the current mode.MaxHistorySize()
Returns the maximum number of history items (20).Utility Methods
Reset()
Resets the calculator to initial state.Whether to clear memorized numbers
- Switches to Standard mode
- Sets degree mode (if in Scientific)
- Clears all entries
- Disables exponential format
- Optionally clears memory
IsEngineRecording()
Checks if the engine is recording input (building an expression).IsInputEmpty()
Checks if the current input is empty.SetRadix()
Sets the number base for Programmer mode.Radix type: Hex, Decimal, Octal, or Binary
GetResultForRadix()
Gets the current result formatted in a specific radix.The radix (2, 8, 10, or 16)
Number of digits of precision
Whether to group digits with separators
SetPrecision()
Changes the calculation precision.Number of digits of precision
DecimalSeparator()
Gets the decimal separator character for the current locale.GetCurrentDegreeMode()
Returns the current angle mode for trigonometric functions.CommandDEG, CommandRAD, or CommandGRAD
GetDisplayCommandsSnapshot()
Gets a snapshot of the current expression commands for display.Enumerations
CalculatorMode
Defines the calculator modes.MemoryCommand
Commands for memory operations.CalculatorPrecision
Default precision values for each mode.ICalcDisplay Interface
Callbacks that must be implemented by the display:See Also
- CCalcEngine - Core calculation engine
- RatPack - Infinite precision arithmetic