#include <tipsdlg.h>
Inheritance diagram for TipsDlg:
Public Member Functions | |
TipsDlg () | |
This default constructor provides the only way to instantiate TipsDlg objects. | |
virtual | ~TipsDlg () |
This destructor is executed whether the user had pressed the escape key or clicked on the close button. If the user had pressed the escape key, we still need to update the NextID in the ini file with the latest position so that we don't repeat the tips! | |
virtual void | Do (OpDescriptor *) |
Overrides the base class Op::Do function to perform the operation of displaying the Tip of the Day dialog. | |
Static Public Member Functions | |
static BOOL | Init () |
Completes the work of the constructor, but returning an error if complete construction was not possible. | |
static OpState | GetState (String_256 *, OpDescriptor *) |
Provides menu greying. Not that there's much to grey. | |
static BOOL | ShowAtStartUp () |
Determines whether or not the Tip of the Day dialog should be shown at start up. | |
static CDlgResID | IDD () |
Static Public Attributes | |
static const CDlgMode | Mode = MODELESS |
Protected Types | |
typedef UINT32 | ResourceID |
Protected Member Functions | |
virtual BOOL | Create () |
Overrides the base class's Create() member to set up additional class specific data. | |
virtual BOOL | OnInitDialog () |
Initializes this TipsDlg ready for display. | |
virtual MsgResult | Message (Msg *pMessage) |
Dispatches messages to various other member functions beginning On... | |
void | OnNextTip () |
Responds to a user's request for the Next Tip by displaying it. | |
void | OnCommit () |
Performs any operations after the user has pressed the close button. | |
void | OnRedraw (ReDrawInfoType *pRedrawInfo) |
Redraws the dialog in response to a DIM_REDRAW message. | |
void | OnMoreHelp () |
Responds to a user's request for more help for a tip by invoking the on-line help. | |
BOOL | CreateTipGadget () |
Creates a CCStatic gadget for the Tip text Notes: Unfortunately we can't get the redraw messages for statics out of the dialog manager. So we have to let CCStatic take care of it. There's a nasty bit of hard-coded dialog in here, re.the size. | |
void | GetNextTipString () |
Stores the next tip string in m_strTip and the position of the '#' in that string in m_iHashPosition A TIP should be of the form "tip string#nnnn" where nnnn is the help topic ID. | |
void | GetTipString (ResourceID StringID) |
Support function that gets the Tip string defined by the given resource id The resource should have been declared using the TIP() macro declared in tipsres.h. | |
HelpID | GetTipHelpID () |
Allows the user to be given further information regarding the current tip. See Also: OnMoreHelp(). | |
void | DrawTipString () |
Renders the current (m_strTip) tip. | |
BOOL | DrawBitmap (ResourceID BitmapID, DocRect &RedrawRect) |
Renders the given bitmap in the given rectangle. | |
Protected Attributes | |
BOOL | m_bTipOK |
String_256 | m_strTip |
INT32 | m_iHashPosition |
BOOL | m_bSentInvalid |
DialogMsg * | m_pCurrentMsg |
RenderRegion * | m_pRenderer |
CCStatic * | m_pTipTextGadget |
Static Protected Attributes | |
static UINT32 | g_uNextID = MIN_TIP_ID |
static BOOL | g_bStartUp = TRUE |
Definition at line 129 of file tipsdlg.h.
|
|
|
This default constructor provides the only way to instantiate TipsDlg objects.
Definition at line 244 of file tipsdlg.cpp. 00244 : 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 }
|
|
This destructor is executed whether the user had pressed the escape key or clicked on the close button. If the user had pressed the escape key, we still need to update the NextID in the ini file with the latest position so that we don't repeat the tips!
Definition at line 274 of file tipsdlg.cpp. 00275 { 00276 Camelot.SetPrefValue(szSection, szIntNextID, &g_uNextID); 00277 }
|
|
Overrides the base class's Create() member to set up additional class specific data.
Reimplemented from DialogOp. Definition at line 293 of file tipsdlg.cpp. 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 }
|
|
Creates a CCStatic gadget for the Tip text Notes: Unfortunately we can't get the redraw messages for statics out of the dialog manager. So we have to let CCStatic take care of it. There's a nasty bit of hard-coded dialog in here, re.the size.
Definition at line 325 of file tipsdlg.cpp. 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 }
|
|
Overrides the base class Op::Do function to perform the operation of displaying the Tip of the Day dialog.
Reimplemented from Operation. Definition at line 356 of file tipsdlg.cpp.
|
|
Renders the given bitmap in the given rectangle.
Definition at line 746 of file tipsdlg.cpp. 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 }
|
|
Renders the current (m_strTip) tip.
Definition at line 722 of file tipsdlg.cpp. 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 }
|
|
Stores the next tip string in m_strTip and the position of the '#' in that string in m_iHashPosition A TIP should be of the form "tip string#nnnn" where nnnn is the help topic ID.
Definition at line 628 of file tipsdlg.cpp. 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 }
|
|
Provides menu greying. Not that there's much to grey.
Definition at line 208 of file tipsdlg.cpp. 00209 { 00210 OpState opState; 00211 return opState; 00212 }
|
|
Allows the user to be given further information regarding the current tip. See Also: OnMoreHelp().
Definition at line 704 of file tipsdlg.cpp. 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 }
|
|
Support function that gets the Tip string defined by the given resource id The resource should have been declared using the TIP() macro declared in tipsres.h.
Definition at line 664 of file tipsdlg.cpp. 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 }
|
|
Definition at line 145 of file tipsdlg.h. 00145 {return _R(IDD_TIP);}
|
|
Completes the work of the constructor, but returning an error if complete construction was not possible.
Reimplemented from SimpleCCObject. Definition at line 163 of file tipsdlg.cpp. 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 }
|
|
Dispatches messages to various other member functions beginning On...
Reimplemented from DialogOp. Definition at line 414 of file tipsdlg.cpp. 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 }
|
|
Performs any operations after the user has pressed the close button.
Definition at line 500 of file tipsdlg.cpp. 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 }
|
|
Initializes this TipsDlg ready for display.
Definition at line 376 of file tipsdlg.cpp. 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 }
|
|
Responds to a user's request for more help for a tip by invoking the on-line help.
Definition at line 600 of file tipsdlg.cpp. 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 }
|
|
Responds to a user's request for the Next Tip by displaying it.
Definition at line 472 of file tipsdlg.cpp. 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 }
|
|
Redraws the dialog in response to a DIM_REDRAW message.
Definition at line 517 of file tipsdlg.cpp. 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 }
|
|
Determines whether or not the Tip of the Day dialog should be shown at start up.
Definition at line 225 of file tipsdlg.cpp. 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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|