![]() |
Web Development »
Applications & Tools »
Tools with source code
Intermediate
License: The Creative Commons Attribution-ShareAlike 2.5 License
Calendar Plug-in for .dan.g.'s ToDoList - In 10 Easy Steps™By [d3m0n]A Calendar UI extension component for the ToDoList, giving you a timeline view of your tasks |
C++ (VC6), Windows, Visual-Studio, MFC, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
(Current version: 1.0 - released 6 Jun, 2008)
This article is an attempt to describe how I created a Calendar plug-in for .dan.g.'s ToDoList. It may be useful to you for two reasons:
If you're here for reason #1 and scared of reason #2, please don't worry. Read on - it's easy!
When I started using .dan.g.'s mighty ToDoList, it made me rethink the way I approached my tasks. Previously I had to try to actually remember (ugh) every minor thing that needed to be done before I could regard a task as fully completed. Now to be honest I have a memory worse than a goldfish, so finding the ToDoList was a godsend. I now break down all my tasks recursively into squillions of subtasks and my memory is no longer required (leaving it free to concentrate on other equally important things, such as my favourite Bill Hicks jokes, or the theme tune to the Mysterious Cities Of Gold. "Aaaaaah ahaa ahaaaaa someday we will find the cities of gold..." - quality!).
Having a large number of tasks and subtasks poses a problem because it is difficult to figure out how far ahead/behind of schedule you are (after all, these are what your boss cares about. Get 'em wrong and it could mean a visit to the Jobcentre. Again.). So, I started spending a lot of time setting the Start Date and Due Date for all my tasks, but this just wasn't enough. I couldn't visualize my progress in my head, no matter how accurate/up-to-date the Start/Due Dates were. What I wanted was a quick overview of my progress against the schedule, a visualization of my project.
What I needed was a calendar-type view within the ToDoList itself. Of course, I could have tried to export my data somehow and import it into another program, but where's the fun in that? This was already on .dan.g.'s own ToDoList, so I decided to help him out. It's the least I could do. And he gave me extensive advice on how to go about writing my own ToDoList Calendar plug-in.
The file CalendarExt.dll needs to be placed in the ToDoList directory.
The Calendar can be activated from ToDoList's [Tools->Calendar] menu item. This displays the modeless Calendar window for the active task list (switching task lists will hide/show the Calendar window appropriately). The Calendar window is split into two panes:
MiniCalendar BigCalendar MiniCalendar pane initially contains the current month and the next month. If the window is resized large enough, it will also contain the following month. MiniCalendar will jump to that date in the BigCalendar. BigCalendar pane initially contains each date in the 6-week period surrounding today's date. BigCalendar contains all tasks in the active task list with a Start/Due Date equal to this date. MiniCalendar pane can be hidden/shown using the [View->Mini Calendar] menu item. BigCalendar can be manoeuvred using the scrollbars, mouse wheel, arrow keys and PageUp/PageDown. BigCalendar (or selecting it using the arrow keys and pressing Return) will jump to that task in the active task list. BigCalendar. BigCalendar. The BigCalendar and MiniCalendar are third party classes which I most graciously "stole" (is that the right word?) from other articles at The Code Project. If I use someone else's class, I like to spend some time working out what it is doing and why it is doing it. I like to rewrite the code in my own style so I can (a) understand it better and (b) debug it easier. Any part of the class I don't need will be ripped out. This is what I've done with the following three classes that I used in the Calendar:
BigCalendar) is a beautiful custom-drawn calendar by Frederic Rezeau. The main change I made to this class was to use CListBoxes in each date instead of drawing the tasks as text directly. MiniCalendar) is a cool Microsoft Outlook-style mini-calendar by Matt Gullett. CListBoxes in the BigCalendar are CTransparentListBoxes by Ali Rafiee. I also added tooltip support to this class. ToDoList uses plug-ins to provide a number of ways of achieving different customizations to the main application. There are several types of plug-ins already in use, including Encryption, Custom Comments, Task Importers/Exporters and UI Extensions. The benefits of using a plug-in architecture include:
All of ToDoList's plug-ins are architected the same way: the plug-in resides in a DLL and exports one (or more) C functions (their names are unmangled/undecorated). One of these exported functions is typically a CreateXXX() function that returns a pointer to a pure virtual interface (class) that ToDoList then uses to communicate with the plug-in. In the case of UI Extension plug-ins, this function is called CreateUIExtensionInterface().
Whilst a full discussion of pure virtual interfaces is beyond the scope of this article, essentially they define a contract which the plug-in commits to supporting without requiring any explicit binding between the two components. You might say that they are the C++ equivalent of calling GetProcAddress on a loaded DLL. Pure virtual interfaces are at the heart of COM and are a proven method for decoupling the interface and implementation of a component.
For UI Extension plug-ins, ToDoList provides two interfaces, both located in Shared\IUIExtension.h:
IUIExtension interface is a high-level interface that allows ToDoList to create plug-in windows and also obtain menu-text and icon information from the plug-in so that a menu item can be added to the [Tools] menu for each plug-in. IUIExtensionWindow interface represents the window that the user will actually interact with. This is where the guts of the plug-in reside, responding to editing notifications from ToDoList and optionally sending selection events back to ToDoList when the user clicks on something. Here are the 10 Easy Steps™ I used to create a basic working Calendar plug-in:
CalendarExt. Change the linker settings so that CalendarExt.dll is built to the same folder as ToDoList.exe. CCalendarExtApp and CCalendarFrameWnd, derived from IUIExtension and IUIExtensionWindow respectively, containing stubs for all the pure virtual functions. CreateUIExtensionInterface (also defined in Shared\IUIExtension.h) which simply returns a pointer to a newly created (or static) instance of CCalendarExtApp. CCalendarExtApp::GetMenuText function to return "Calendar" and implement the CCalendarExtApp::GetIcon() function to return an appropriate icon. CCalendarFrameWnd::Create() to create a suitable window for the user to interact with. I chose to derive CCalendarFrameWnd from CFrameWnd, but you could use a modeless CDialog, CPropertySheet, CView or whatever. CCalendarExtApp::CreateExtensionWindow() to return a pointer to a newly created instance of CCalendarFrameWnd and call this window's Create function. Note: ToDoList looks after all the display and hiding of plug-in windows; the plug-in's responsibility is simply to implement the pure virtual interface sensibly.
CCalendarFrameWnd class to display the CBigCalendarCtrl and CMiniCalendarCtrl windows in its client area, and to respond to resizing events. CCalendarFrameWnd::Update() gets called. From here, I update my CCalendarData object (a class to cache all tasks for the active task list) with the updated information. I then call a TasklistUpdated function in both the CBigCalendarCtrl and CMiniCalendarCtrl objects, which tells them to update their views using the latest data. WM_TDCM_TASKLINK message to the main ToDoList application window, along with the ID of the clicked task. ToDoList interprets this message and selects the specified task in the active task list. That's it! I won't bore you with further details about how the Big/MiniCalendars work. You haven't got time for that! What are you waiting for? Go write a plug-in now!!
This version of the ToDoList Calendar plug-in is ready to go with version 5.4 or later. Please keep an eye on this page for updates. All comments, bugs, grumbles or suggestions are welcome.
Big thanks go to the writers of the three classes that I, erm... borrowed, namely:
A massive thanks also obviously to .dan.g., who in my opinion is an inspiration to open source coders. I don't think I've ever come across such a nice guy with such quick bug/request turnaround and dedication to his user-base. Dan has been very patient with me and helped me lots with his plug-in architecture and suggestions for the Calendar, helping me to fix some dodgy bugs, as well as giving me loads of information for this article!
General
News
Question
Answer
Joke
Rant
Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads.
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 10 Jun 2008 Editor: Deeksha Shenoy |
Copyright 2008 by [d3m0n] Everything else Copyright © CodeProject, 1999-2010 Web21 | Advertise on the Code Project |