tipsdlg.cpp

Go to the documentation of this file.
00001 // $Id: tipsdlg.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 // Implementation of the TipOfTheDay dialog class
00100 
00101 #include "camtypes.h"
00102  
00103 #include "tipsdlg.h"   
00104 //#include "tipsres.h"   
00105 //#include "tips.h"
00106 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 #include "camelot.h"
00108 //#include "dialogop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 #include "ccstatic.h"   
00110 #include "dragmgr.h"
00111 //#include "ensure.h"   - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "errors.h"  - in camtypes.h [AUTOMATICALLY REMOVED]
00113 
00114 //#include "rndrgn.h"           // For render-into-dialogue support - in camtypes.h [AUTOMATICALLY REMOVED]
00115 //#include "txtattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "dlgcol.h"
00117 //#include "fillval.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00118 #include "nodebmp.h"
00119 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00120 #include "wbitmap.h"
00121 
00122 #include "helpuser.h"
00123 //#include "mario.h"            // for _R(IDS_BARSINFO_ONE)
00124 //#include "ollie.h"            // for _R(IDS_TIPOFTHEDAYMENU)
00125 
00126 
00127 CC_IMPLEMENT_DYNCREATE(TipsDlg, DialogOp)   
00128 
00129 
00130 // This line MUST go after all CC_IMPLEMENT lines
00131 #define new CAM_DEBUG_NEW
00132 
00133 
00134 const DocRect g_StaticSize(76,55,138,79);
00135 
00136 
00137 const UINT32 MIN_TIP_ID = _R(IDS_TIP_1);
00138 
00139 const CDlgMode TipsDlg::Mode = MODELESS;        // The dialog is modeless  
00140 
00141 static TCHAR szSection[] = _T("Tip");
00142 static TCHAR szIntNextID[] = _T("NextID");
00143 static TCHAR szIntStartup[] = _T("StartUp");
00144 
00145 
00146 UINT32 TipsDlg::g_uNextID = MIN_TIP_ID;
00147 BOOL TipsDlg::g_bStartUp = TRUE;
00148 
00149 
00150 /********************************************************************************************
00151 
00152 >   BOOL TipsDlg::Init()
00153 
00154     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00155     Created:    03/08/96
00156     Returns:    FALSE if initialization fails
00157     Purpose:    Completes the work of the constructor, but returning an error if complete
00158                 construction was not possible.
00159     Errors:     -
00160     SeeAlso:    TipsDlg::TipsDlg()
00161 
00162 ********************************************************************************************/
00163 BOOL TipsDlg::Init()
00164 {  
00165     if (!RegisterOpDescriptor
00166     (
00167         0,                          // toolID
00168         _R(IDS_TIPOFTHEDAYMENU),    // Text for Menu
00169         CC_RUNTIME_CLASS(TipsDlg),
00170         OPTOKEN_TIPSDLG,            // Token to Invoke dialog
00171         TipsDlg::GetState,          // GetState for menu disabling
00172         0,                          // HelpID
00173         _R(IDS_BBL_TIPDLG),             // BubbleID
00174         0,                          // ResourceID
00175         0,                          // BitmapID
00176         SYSTEMBAR_ILLEGAL,          // Bar ID
00177         FALSE,                      // Recieve system messages
00178         FALSE,                      // Smart duplicate operation
00179         TRUE,                       // Clean operation
00180         NULL,                       // No vertical counterpart
00181         _R(IDS_BARSINFO_ONE)            // String for one copy only
00182     ))
00183     {
00184         return FALSE;
00185     }
00186 
00187     if (!Camelot.DeclareSection(szSection, 2) ||
00188         !Camelot.DeclarePref(szSection, szIntNextID, &g_uNextID) ||
00189         !Camelot.DeclarePref(szSection, szIntStartup, &g_bStartUp)
00190     )
00191     {
00192         return FALSE;
00193     }
00194     return TRUE;
00195 }
00196 
00197 
00198 
00199 /********************************************************************************************
00200 
00201 >   OpState TipsDlg::GetState(String_256*, OpDescriptor*)
00202 
00203     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00204     Created:    03/08/96
00205     Purpose:    Provides menu greying. Not that there's much to grey.
00206 
00207 ********************************************************************************************/
00208 OpState TipsDlg::GetState(String_256*, OpDescriptor*)
00209 {    
00210     OpState opState;
00211     return opState;
00212 }
00213          
00214 
00215 /********************************************************************************************
00216 
00217 >   BOOL TipsDlg::ShowAtStartUp()
00218 
00219     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00220     Created:    08/08/96
00221     Purpose:    Determines whether or not the Tip of the Day dialog should be shown at start
00222                 up.
00223 
00224 ********************************************************************************************/
00225 BOOL TipsDlg::ShowAtStartUp()
00226 {
00227     // We need to find out whether to provide the dialog at startup
00228     // If no startup preference, we assume that the Tips on startup is checked TRUE.
00229     Camelot.GetPrefValue(szSection, szIntStartup, &g_bStartUp);
00230 
00231     return  g_bStartUp;
00232 }
00233 
00234 
00235 /********************************************************************************************
00236 
00237 >   TipsDlg::TipsDlg()
00238 
00239     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00240     Created:    03/08/96
00241     Purpose:    This default constructor provides the only way to instantiate TipsDlg objects
00242 
00243 ********************************************************************************************/
00244 TipsDlg::TipsDlg() : DialogOp(TipsDlg::IDD(), TipsDlg::Mode)
00245 {
00246     m_bSentInvalid  = FALSE;
00247 
00248     m_bTipOK        = FALSE;
00249     m_iHashPosition = 0;
00250 
00251     m_pCurrentMsg   = NULL;
00252     m_pRenderer     = NULL;
00253 
00254     m_pTipTextGadget    = NULL;
00255 
00256     Camelot.GetPrefValue(szSection, szIntNextID, &g_uNextID);
00257     // Now try to get the next tip
00258     GetNextTipString();
00259 }        
00260 
00261 
00262 /********************************************************************************************
00263 
00264 >   TipsDlg::~TipsDlg()
00265 
00266     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00267     Created:    03/08/96
00268     Purpose:    This destructor is executed whether the user had pressed the escape key
00269                 or clicked on the close button. If the user had pressed the escape key,
00270                 we still need to update the NextID in the ini file with the  latest position
00271                 so that we don't repeat the tips! 
00272 
00273 ********************************************************************************************/
00274 TipsDlg::~TipsDlg()
00275 {
00276     Camelot.SetPrefValue(szSection, szIntNextID, &g_uNextID);
00277 }
00278 
00279 
00280 /********************************************************************************************
00281 
00282 >   BOOL TipsDlg::Create()
00283 
00284     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00285     Created:    03/08/96
00286     Returns:    TRUE if creation successful
00287                 FALSE if it fails
00288     Purpose:    Overrides the base class's Create() member to set up additional class
00289                 specific data.
00290     SeeAlso:    DialogOp::Create()
00291 
00292 ********************************************************************************************/
00293 BOOL TipsDlg::Create()
00294 {                            
00295     if (!DialogOp::Create())
00296     {
00297         return FALSE;
00298     }
00299 
00300     // Create the static control to contain the tip text
00301     if (!CreateTipGadget())
00302     {
00303         return FALSE;
00304     }
00305 
00306     OnInitDialog();     // Set the initial control values
00307     return TRUE; 
00308 }           
00309 
00310 
00311 /********************************************************************************************
00312 
00313 >   BOOL TipsDlg::CreateTipGadget()
00314 
00315     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00316     Created:    03/08/96
00317     Returns:    TRUE if creation successful
00318                 FALSE if it fails
00319     Purpose:    Creates a CCStatic gadget for the Tip text
00320     Notes:      Unfortunately we can't get the redraw messages for statics out of the
00321                 dialog manager. So we have to let CCStatic take care of it.
00322                 There's a nasty bit of hard-coded dialog in here, re.the size
00323 
00324 ********************************************************************************************/
00325 BOOL TipsDlg::CreateTipGadget()
00326 {
00327     m_pTipTextGadget = new CCStatic;
00328     if (m_pTipTextGadget == NULL)
00329     {
00330         return FALSE;
00331     }
00332 
00333 //  GetGadget()->Size();    // Ha ha ha
00334 
00335     // Create the window for it
00336     if (!m_pTipTextGadget->Create(this, g_StaticSize, _R(IDC_TIPSTRING), m_strTip.MaxLength()))
00337     {
00338         return FALSE;
00339     }
00340 
00341     return TRUE;
00342 }
00343 
00344 
00345 
00346 /********************************************************************************************
00347 
00348 >   void TipsDlg::Do(OpDescriptor*)
00349 
00350     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00351     Created:    03/08/96
00352     Purpose:    Overrides the base class Op::Do function to perform the operation of
00353                 displaying the Tip of the Day dialog.
00354 
00355 ********************************************************************************************/
00356 void TipsDlg::Do(OpDescriptor*)
00357 {
00358     if (!Create())
00359     {
00360         return;
00361     }
00362     Open();
00363 }
00364 
00365 
00366 /********************************************************************************************
00367 
00368 >   BOOL TipsDlg::OnInitDialog()
00369 
00370     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00371     Created:    03/08/96
00372     Returns:    FALSE if initialisation failed
00373     Purpose:    Initializes this TipsDlg ready for display
00374 
00375 ********************************************************************************************/
00376 BOOL TipsDlg::OnInitDialog()
00377 {
00378     // If Tips file does not exist then disable NextTip
00379     if (!m_bTipOK)
00380     {
00381         EnableGadget(_R(IDC_NEXTTIP), FALSE);
00382 
00383     }
00384     // Check there's more help & disable the more button if there isn't
00385     HelpID helpID = GetTipHelpID();
00386     if (helpID == 0)
00387     {
00388         EnableGadget(_R(IDC_MORE), FALSE);
00389     }
00390     else
00391     {
00392         EnableGadget(_R(IDC_MORE), TRUE);
00393     }       
00394 
00395     // Tip should be some error message if not OK
00396     DrawTipString();
00397 
00398     SetBoolGadgetSelected(_R(IDC_STARTUP), g_bStartUp);
00399 
00400     return TRUE;
00401 }
00402 
00403         
00404 
00405 /********************************************************************************************
00406 
00407 >   MsgResult TipsDlg::Message(Msg* pMessage)
00408 
00409     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00410     Created:    03/08/96
00411     Purpose:    Dispatches messages to various other member functions beginning On...
00412 
00413 ********************************************************************************************/
00414 MsgResult TipsDlg::Message(Msg* pMessage)
00415 {
00416     if (IS_OUR_DIALOG_MSG(pMessage))
00417     {
00418         m_pCurrentMsg = (DialogMsg*)pMessage;
00419         
00420         switch (m_pCurrentMsg->DlgMsg)
00421         {
00422             case DIM_CREATE:
00423             {
00424                 break;
00425             }
00426 
00427             case DIM_REDRAW:
00428             {   
00429                 // Get the redraw information from the message
00430                 ReDrawInfoType* pReDrawInfo = (ReDrawInfoType*) m_pCurrentMsg->DlgMsgParam;
00431                 OnRedraw(pReDrawInfo);
00432                 break;
00433             }
00434 
00435             case DIM_COMMIT:
00436                 OnCommit();     // and fall through...
00437 
00438             case DIM_CANCEL:
00439                 Close();        // Close and destroy the dialog 
00440                 delete m_pTipTextGadget;
00441                 End();          // WARNING: Destroys this!!!
00442                 return (DLG_EAT_IF_HUNGRY((DialogMsg*)pMessage));   // End() destroyed m_...
00443 
00444             case DIM_LFT_BN_CLICKED:
00445                 // A control on the dialog box has been clicked...
00446                 switch (m_pCurrentMsg->GadgetID)
00447                 {
00448                     case _R(IDC_MORE):      // clicked on "Tell me more..."
00449                         OnMoreHelp();
00450                         return (DLG_EAT_IF_HUNGRY(m_pCurrentMsg));
00451 
00452                     case _R(IDC_NEXTTIP):
00453                         OnNextTip();
00454                         break;
00455                 }
00456                 break; // DIM_LFT_BN_CLICKED        
00457         }
00458     }
00459     return OK;  
00460 }  
00461 
00462 
00463 /********************************************************************************************
00464 
00465 >   void TipsDlg::OnNextTip()
00466 
00467     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00468     Created:    03/08/96
00469     Purpose:    Responds to a user's request for the Next Tip by displaying it.
00470 
00471 ********************************************************************************************/
00472 void TipsDlg::OnNextTip()
00473 {
00474     GetNextTipString();
00475 
00476     // Check there's more help & disable the more button if there isn't
00477     HelpID helpID = GetTipHelpID();
00478     if (helpID == 0)
00479     {
00480         EnableGadget(_R(IDC_MORE), FALSE);
00481     }
00482     else
00483     {
00484         EnableGadget(_R(IDC_MORE), TRUE);
00485     }       
00486 
00487     DrawTipString();
00488 }
00489 
00490 
00491 /********************************************************************************************
00492 
00493 >   void TipsDlg::OnCommit()
00494 
00495     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00496     Created:    03/08/96
00497     Purpose:    Performs any operations after the user has pressed the close button
00498 
00499 ********************************************************************************************/
00500 void TipsDlg::OnCommit()
00501 {
00502     // Update the startup information stored in the INI file
00503     g_bStartUp = GetBoolGadgetSelected(_R(IDC_STARTUP));
00504     Camelot.SetPrefValue(szSection, szIntStartup, &g_bStartUp);
00505 }
00506 
00507 
00508 /********************************************************************************************
00509 
00510 >   void TipsDlg::OnRedraw(ReDrawInfoType* pRedrawInfo)
00511 
00512     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00513     Created:    03/08/96
00514     Purpose:    Redraws the dialog in response to a DIM_REDRAW message
00515 
00516 ********************************************************************************************/
00517 void TipsDlg::OnRedraw(ReDrawInfoType* pRedrawInfo)
00518 {
00519     // Use the actual size of the window as our scale
00520     DocRect RedrawRect(0, 0, pRedrawInfo->dx, pRedrawInfo->dy);
00521 
00522     m_pRenderer = CreateGRenderRegion(&RedrawRect, pRedrawInfo);
00523     if (m_pRenderer != NULL)
00524     {
00525         // Interlock redraw with the drag manager to ensure we don't redraw over any drag
00526         // blobs
00527         DragManagerOp::RedrawStarting(WindowID, m_pCurrentMsg->GadgetID);
00528 
00529         DialogColourInfo defaultColours;            // Object supplying Host OS redraw colours
00530 
00531         m_pRenderer->SaveContext();
00532 
00533         // Paint the background
00534         m_pRenderer->SetLineWidth(0);
00535         m_pRenderer->SetLineColour(COLOUR_WHITE);
00536         m_pRenderer->SetFillColour(COLOUR_WHITE);
00537         m_pRenderer->DrawRect(&RedrawRect);
00538         switch (m_pCurrentMsg->GadgetID)
00539         {
00540             case _R(IDC_BITMAP):
00541             {
00542                 // Draw bitmap in top corner and validate only top portion of window
00543                 DrawBitmap(_R(IDB_LIGHTBULB), RedrawRect);
00544                 break;
00545             }
00546             case _R(IDC_DIDYOUKNOW):
00547             {
00548                 
00549                 DrawBitmap(_R(IDB_DIDYOU), RedrawRect);
00550 /*
00551                 m_pRenderer->SetFixedSystemTextColours( &defaultColours.TextFore(), 
00552                                                         &defaultColours.TextBack());
00553                 // Draw out "Did you know..." message next to the bitmap
00554                 String_256 strMessage;
00555                 strMessage.Load(_R(IDS_DIDYOUKNOW));
00556                 DrawText(&strMessage, RedrawRect, ALN_CENTRE);
00557 */
00558                 break;
00559                 // Just draw a white rectangle with the text on it
00560             }
00561     
00562             default:
00563             {
00564                 TRACEUSER( "Colin", _T("Invalidated - m_bSentInvalid %d\n"), m_bSentInvalid);
00565                 if (!m_bSentInvalid)
00566                 {
00567                     m_bSentInvalid = TRUE;
00568                     m_pTipTextGadget->Invalidate(pRedrawInfo->pClipRect);
00569                 }
00570                 else
00571                 {
00572                     m_bSentInvalid = FALSE;
00573                 }
00574                 break;
00575             }
00576         }
00577 
00578 
00579         m_pRenderer->RestoreContext();
00580 
00581         DestroyGRenderRegion(m_pRenderer);
00582         // And turn off the drag redraw interlock
00583         DragManagerOp::RedrawFinished();
00584 
00585     }
00586 }
00587 
00588 
00589 /********************************************************************************************
00590 
00591 >   void TipsDlg::OnMoreHelp()
00592 
00593     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00594     Created:    03/08/96
00595     Returns:    A MsgResult determining how the message handler should continue processing
00596     Purpose:    Responds to a user's request for more help for a tip by invoking the on-line
00597                 help.
00598 
00599 ********************************************************************************************/
00600 void TipsDlg::OnMoreHelp()
00601 {
00602     HelpID helpID = GetTipHelpID();
00603     if (helpID > 0)             // Invoke the help system
00604     {
00605         HelpUserTopic(helpID);
00606     }
00607     else
00608     {
00609         GetTipString(_R(IDS_SORRY_NO_HELP));
00610         DrawTipString();
00611     }
00612 }
00613 
00614 
00615 
00616 /********************************************************************************************
00617 
00618 >   void TipsDlg::GetNextTipString()
00619 
00620     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00621     Created:    03/08/96
00622     Purpose:    Stores the next tip string in m_strTip
00623                 and the position of the '#' in that string in m_iHashPosition
00624                 A TIP should be of the form "tip string#nnnn" where nnnn is the help topic
00625                 ID.
00626 
00627 ********************************************************************************************/
00628 void TipsDlg::GetNextTipString()
00629 {
00630     // Check the next tip id is in the designated range
00631     if (g_uNextID < MIN_TIP_ID || g_uNextID > MAX_TIP_ID)
00632     {
00633         GetTipString(_R(IDS_INVALID_TIP_ID));
00634         g_uNextID = MIN_TIP_ID;
00635         return;
00636     } 
00637 
00638     // Attempt to get the tip string resource
00639     GetTipString(g_uNextID);
00640 
00641     // Get ready to read the next one
00642     ++g_uNextID;
00643     // If we've run out of tips, start all over...
00644     if (g_uNextID > MAX_TIP_ID)
00645     {
00646         g_uNextID = MIN_TIP_ID;
00647     }
00648 }
00649 
00650 
00651 
00652 /********************************************************************************************
00653 
00654 >   void TipsDlg::GetTipString(ResourceID StringID)
00655 
00656     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00657     Created:    03/08/96
00658     Inputs:     StringID : the ID of the tip resource string to get
00659     Purpose:    Support function that gets the Tip string defined by the given resource id
00660                 The resource should have been declared using the TIP() macro declared in
00661                 tipsres.h
00662 
00663 ********************************************************************************************/
00664 void TipsDlg::GetTipString(ResourceID StringID)
00665 {
00666     // Be pessimistic and assume we won't be able to get the string
00667     m_bTipOK = FALSE;
00668 
00669     // Attempt to get the tip string resource
00670     if (!m_strTip.Load(StringID))
00671     {
00672         if (!m_strTip.Load(_R(IDS_UNABLE_TO_LOAD)))
00673         {
00674             ERROR3("Can't even load unable to load message");
00675             return;
00676         }
00677     } 
00678 
00679     // The resource should be of the form tip#nnn
00680     // Find the '#' in the resource string and remember its position
00681     m_iHashPosition = m_strTip.FindNextChar(TEXT('#'), 0);
00682     if (m_iHashPosition <= 0)
00683     {
00684         ERROR3("m_strTip doesn't contain a help id");
00685         return;
00686     }
00687     
00688     // We managed to get a tip, so signal that everyone can use it
00689     m_bTipOK = TRUE;
00690 }
00691 
00692 
00693 /********************************************************************************************
00694 
00695 >   HelpID TipsDlg::GetTipHelpID()
00696 
00697     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00698     Created:    03/08/96
00699     Returns:    The HelpID associated with the current tip
00700     Purpose:    Allows the user to be given further information regarding the current tip.
00701     See Also:   OnMoreHelp()
00702 
00703 ********************************************************************************************/
00704 HelpID TipsDlg::GetTipHelpID()
00705 {
00706     INT32 iHashPosition = m_iHashPosition + 2;  // +1 for an annoying quote marks
00707     // Convert the right hand side to a HelpID
00708     HelpID helpID = HelpID(m_strTip.ConvertToInteger(iHashPosition));
00709     return helpID;
00710 }
00711 
00712 
00713 /********************************************************************************************
00714 
00715 >   void TipsDlg::DrawTipString()
00716 
00717     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00718     Created:    03/08/96
00719     Purpose:    Renders the current (m_strTip) tip
00720 
00721 ********************************************************************************************/
00722 void TipsDlg::DrawTipString()
00723 {
00724     String_256 actualTip;
00725 
00726     m_strTip.Left(&actualTip, m_iHashPosition - 1);
00727     m_pTipTextGadget->SetString(&actualTip);
00728     m_bSentInvalid = TRUE;
00729     m_pTipTextGadget->Invalidate();
00730 }
00731 
00732 
00733 /********************************************************************************************
00734 
00735 >   BOOL TipsDlg::DrawBitmap(ResourceID BitmapID, DocRect& RedrawRect)
00736 
00737     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00738     Created:    08/08/96
00739     Inputs:     BitmapID : the resource id of the bitmap to draw
00740                 RedrawRect : the rectangle in which to draw it
00741     Returns:    TRUE if drawn OK
00742                 FALSE otherwise
00743     Purpose:    Renders the given bitmap in the given rectangle
00744 
00745 ********************************************************************************************/
00746 BOOL TipsDlg::DrawBitmap(ResourceID BitmapID, DocRect& RedrawRect)
00747 {
00748     OILBitmap *pOILBitmap = OILBitmap::Create();
00749     if (pOILBitmap == NULL)
00750     {
00751         return FALSE;
00752     }
00753 
00754     if (!pOILBitmap->LoadBitmap(BitmapID))
00755     {
00756         return FALSE;
00757     }
00758 
00759     // Centre the bitmap within the RedrawRect
00760     UINT32 bitmapWidth = pOILBitmap->GetRecommendedWidth();
00761     UINT32 bitmapHeight = pOILBitmap->GetRecommendedHeight();
00762 
00763     UINT32 xOffset = RedrawRect.lo.x + (RedrawRect.Width() - bitmapWidth) / 2;
00764     UINT32 yOffset = RedrawRect.lo.y + (RedrawRect.Height() - bitmapHeight) / 2;
00765 
00766     DocCoord lowCorner(xOffset, yOffset);
00767     DocRect bitmapRect(lowCorner, bitmapWidth, bitmapHeight);
00768 
00769     KernelBitmap bitmap(pOILBitmap, TRUE);
00770     
00771     // Now we need to create a temporary NodeBitmap, which we will
00772     // use to render the bitmap preview.
00773     NodeBitmap* dummyNode = new NodeBitmap();
00774     if (dummyNode == NULL)
00775     {
00776         return FALSE;
00777     }
00778 
00779     // Set the NodeBitmap path to be our RedrawRect and attach the Bitmap to it.
00780     dummyNode->SetUpPath();
00781     dummyNode->CreateShape(bitmapRect);
00782     dummyNode->GetBitmapRef()->SetBitmap(&bitmap);
00783 
00784     // Now render the bitmap preview
00785     dummyNode->Render(m_pRenderer);
00786     delete dummyNode;
00787 
00788     // All OK
00789     return TRUE;
00790 }
00791 
00792 
00793 /********************************************************************************************
00794 
00795 >   void TipsDlg::DrawText(StringBase* pString, DocRect& RedrawRect, Justification justification)
00796 
00797     Author:     Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
00798     Created:    08/08/96
00799     Inputs:     pString : a pointer to the text to be drawn
00800                 RedrawRect: a reference to the rectangle into which the text is to be drawn
00801                 justification : how the text is to be positioned in the RedrawRect
00802     Purpose:    Draw the given text in the given rectangle, aligned as specified.
00803     Notes:      Only JLEFT implemented: centred horizontally & vertically in RedrawRect
00804                 NOT USED - Will be eventually, hopefully
00805 
00806 ********************************************************************************************/
00807 /*  
00808 void TipsDlg::DrawText(StringBase* pString, DocRect& RedrawRect, Justification justification)
00809 {
00810     DocRect stringBounds;
00811 
00812     // Find the text size...
00813     m_pRenderer->GetFixedSystemTextSize(pString, &stringBounds);
00814 
00815     // And then move it depending on the required alignment
00816     switch (justification)
00817     {
00818         case JLEFT:
00819         {
00820             INT32 yCentre = RedrawRect.lo.y + (RedrawRect.Height() - stringBounds.Height()) / 2;
00821             INT32 xOffset = 0;//RedrawRect.lo.x + bitmap.GetRecommendedWidth();
00822             stringBounds.Translate(xOffset, yCentre);
00823         }
00824             
00825     }
00826     m_pRenderer->DrawFixedSystemText(pString, stringBounds);
00827 }
00828 */

Generated on Sat Nov 10 03:47:10 2007 for Camelot by  doxygen 1.4.4