Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

NoteForm.h

Go to the documentation of this file.
00001 /** $Revision: 1.4 $
00002     Last updated: $Date: 2002/09/20 12:21:31 $
00003 
00004     Copyright (C) 2002 Vlad Mereuta <dizzy@users.sourceforge.net>
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00019 
00020 #ifndef __NOTE_FORM__
00021 #define __NOTE_FORM__
00022 
00023 #include <PalmOS.h>
00024 
00025 #include "Form.h"
00026 
00027 
00028 /** class contains code necessary to do note editing 
00029     The data edited by the note field is copied on OK/Delete events to a temporary location which survives after the
00030     form closes. This class is that it holds an internal buffer containing the edited note. The buffer is allocated
00031     dynamically and can be filled in before startup (so that a pre-written note is displayed). The contents of the
00032     buffer can be retrieved at any point, even after the form was closed. This is due to the fact that the actual form
00033     object for the entire life-time of the program.
00034 
00035     @note this form generates update code 5, whenever the calling form needs to check for an update in the note field
00036 */
00037 class NoteForm : public Form 
00038 {
00039 public:
00040     /// constructor; does nothing
00041     NoteForm() FORM_SECTION2;
00042     /// destructor; removes the currently allocated string
00043     ~NoteForm() FORM_SECTION2;
00044     
00045     ///@return singleton reference to this object
00046     static NoteForm* instance() FORM_SECTION2;
00047 
00048     /** @return pointer to the stored note */
00049     Char* getNote() FORM_SECTION2;
00050 
00051     /** the starting string can be a pointer to a character strin or NULL, in which case
00052         new note is assumed; currently stored string is disposed of and re-allocated
00053         The last_caller field is set to 0
00054         @param title_str pointer to the string to be used as title. Note that this string should be allocated somewhere
00055         else and kept allocated until the form closes, as we simply mirror the address and not the location
00056         @param note_str pointer to starting string, if any */
00057     void initForm (Char* title_str, Char* note_str) FORM_SECTION2;
00058 
00059     /** checks whether a given form id should update its data according to data stored by this form
00060         @param form_id id of the form which is checking for updates
00061         @return true if data has been updated and the given form should fetch the new string */
00062     bool updatedData (UInt16 form_id) FORM_SECTION2;
00063     
00064 private:
00065     ///internal reference to this object
00066     static NoteForm* _instance;
00067     ///contains the last valid form which called this form (i.e. to which we exited with ok/delete)
00068     UInt16 _last_caller;
00069     ///current form title
00070     Char* _title;
00071     ///data edited is stored here
00072     Char* _note;
00073     
00074     ///deletes the _note attribute, only if necessary
00075     void deleteNote() FORM_SECTION2;
00076 
00077     /** update the scroll bar with the values hinted by the note field */
00078     void updateScrollBar() FORM_SECTION2;
00079     
00080     /** scroll the note by a specified number of lines
00081         @param lines_to_scroll number of lines to scroll (positive for down, negative for up
00082         @param update_scroll_bar if true, force a scrollbar update */
00083     void scroll (Int16 lines_to_scroll, Boolean update_scroll_bar) FORM_SECTION2;
00084     
00085     /** scroll the note a whole page up or down
00086         @param direction direction to scrol in, can be winUp or winDown */
00087     void pageScroll (WinDirectionType direction) FORM_SECTION2;
00088     
00089 
00090     ///called when key down event occurs
00091     Boolean handleKeyDownEvent(WChar key_id, UInt16 modifiers) FORM_SECTION2;
00092     ///called when form open event occurs
00093     Boolean handleOpenEvent() FORM_SECTION2;
00094     /** called when ctl select event occurs
00095             @param control_id id of the control for which the event was generated */
00096     Boolean handleCtlSelectEvent(UInt16 control_id) FORM_SECTION2;
00097     /** handles events generated when field are changed */
00098     Boolean handleFldChangedEvent() FORM_SECTION2;
00099     /** handles events generated by the scrollbar */
00100     Boolean handleSclRepeatEvent(UInt16 new_value, UInt16 value) FORM_SECTION2;
00101 };
00102 
00103 #endif

Generated on Thu Jan 16 23:11:12 2003 for FreeCoins by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002