#include <bars.h>
Inheritance diagram for BarControl:
Public Member Functions | |
BarControl () | |
BarControl (BarControl &other) | |
BarControl & | operator= (BarControl &other) |
void | SetHorzOpDesc (OpDescriptor *pHorzOpDesc) |
Sets the info regarding the horizontal version of this control. | |
void | SetVertOpDesc (OpDescriptor *pVertOpDesc) |
Sets the info regarding the vertical version of this control. | |
const SimpleBarControl * | GetHorzControl () |
const SimpleBarControl * | GetVertControl () |
BarControlInfo | GetBarControlInfo (BOOL Horz) |
Allows you to get hold of all the info you need about the required control. | |
OpDescriptor * | GetOpDescriptor (BOOL Horz) |
For finding the BarControl's opDescriptor. | |
UINT32 | GetBubbleID (BOOL Horz) |
For finding the BarControl's BubbleID. | |
UINT32 | GetStatusID (BOOL Horz) |
For finding the BarControl's StatusID. | |
BOOL | Read (CCLexFile &file) |
Reads a tokenized form of the control from the given file. | |
BOOL | Write (CCLexFile &file) |
Writes a tokenized form of the control to the given file. | |
virtual BOOL | Read (String_256 *) |
Reads the control from the given string This will be in the form of:- Control H "BreakShapes" 0 126 220 V "BreakShapes" 0 126 220. | |
virtual BOOL | Write (String_256 *) |
UINT32 | GetUniqueGadgetID () |
void | SetUniqueGadgetID (UINT32 UniqueGadget) |
BOOL | IsEnabled () |
BOOL | IsVisible () |
void | SetEnabledState (BOOL enabled) |
void | SetVisibleState (BOOL visible) |
Private Member Functions | |
BOOL | ReadSimpleBarControl (String_256 *pString, SimpleBarControl *pSBC) |
Reads a tokenized form of the simple bar control from the given string. | |
BOOL | ReadSimpleBarControl (CCLexFile &file, SimpleBarControl *pSBC) |
Reads a tokenized form of the simple bar control from the given file. | |
void | SetOpDesc (SimpleBarControl *pSimpleBC, OpDescriptor *pOpDesc) |
Sets the info for this control using the given op desc It's intended that this be called when a bar control is added to a bar via the toolbar dialogue interface. | |
Private Attributes | |
SimpleBarControl | Horizontal |
SimpleBarControl | Vertical |
UINT32 | UniqueGadgetID |
BOOL | Enabled |
BOOL | Visible |
Definition at line 235 of file bars.h.
|
Definition at line 240 of file bars.h.
|
|
Definition at line 245 of file bars.h. 00246 { 00247 SetEnabledState(other.IsEnabled()); 00248 SetVisibleState(other.IsVisible()); 00249 Horizontal = other.Horizontal; 00250 Vertical = other.Vertical; 00251 }
|
|
Allows you to get hold of all the info you need about the required control.
Definition at line 3698 of file bars.cpp. 03699 { 03700 if (horz) 03701 return Horizontal.BarCtrlInfo; 03702 else 03703 return Vertical.BarCtrlInfo; 03704 }
|
|
For finding the BarControl's BubbleID.
Reimplemented from BarControlBase. Definition at line 3748 of file bars.cpp. 03749 { 03750 if (horz) 03751 return Horizontal.BubbleID; 03752 else 03753 return Vertical.BubbleID; 03754 }
|
|
Definition at line 263 of file bars.h. 00263 { return (&Horizontal); }
|
|
For finding the BarControl's opDescriptor.
Definition at line 3723 of file bars.cpp. 03724 { 03725 if (horz) 03726 return Horizontal.pOpDesc; 03727 else 03728 return Vertical.pOpDesc; 03729 }
|
|
For finding the BarControl's StatusID.
Reimplemented from BarControlBase. Definition at line 3773 of file bars.cpp. 03774 { 03775 if (horz) 03776 return Horizontal.StatusID; 03777 else 03778 return Vertical.StatusID; 03779 }
|
|
Definition at line 279 of file bars.h. 00279 { return UniqueGadgetID; }
|
|
Definition at line 264 of file bars.h. 00264 { return (&Vertical); }
|
|
Definition at line 282 of file bars.h. 00282 { return Enabled; }
|
|
Definition at line 283 of file bars.h. 00283 { return Visible; }
|
|
Definition at line 253 of file bars.h. 00254 { 00255 SetEnabledState(other.IsEnabled()); 00256 SetVisibleState(other.IsVisible()); 00257 Horizontal = other.Horizontal; 00258 Vertical = other.Vertical; 00259 return *this; 00260 }
|
|
Reads the control from the given string This will be in the form of:- Control H "BreakShapes" 0 126 220 V "BreakShapes" 0 126 220.
Implements BarItem. Definition at line 3879 of file bars.cpp. 03880 { 03881 ERROR2IF(pString == NULL,FALSE,"BarControl::Read given null parameters!"); 03882 03883 // We will enter here having read in the Control section of the string so we just 03884 // need to decode the following sections. 03885 // This can consist of an H section and/or a V section. 03886 03887 // This text must not be internationalised 03888 //const TCHAR SPACE = TEXT(' '); 03889 const TCHAR H = TEXT('H'); 03890 const TCHAR V = TEXT('V'); 03891 const TCHAR B = TEXT('B'); 03892 03893 INT32 pos = 0; 03894 03895 // Everything is hunky dory at the moment! ER NOT! 03896 BOOL AllIsWell = FALSE; 03897 03898 // Turn on the exceptions function in the string reading class 03899 StringBase::EnableExceptionHandler(); 03900 03901 String_256 Name(*pString); 03902 03903 try 03904 { 03905 // See if we have an H or B as the descriptor of the control 03906 // B defines both controls at the same time 03907 if (Name[pos] == H) 03908 { 03909 // See if there is an H command and then toast it and the supposed trailing space 03910 // if that is successful 03911 pos = Name.FindNextChar(H); 03912 Name.Remove(0, pos+2); 03913 03914 AllIsWell = ReadSimpleBarControl(&Name, &Horizontal); 03915 03916 if (AllIsWell) 03917 { 03918 // See if there is an V command and then toast it and the supposed trailing space 03919 // if that is successful 03920 pos = Name.FindNextChar(V); 03921 Name.Remove(0, pos+2); 03922 03923 AllIsWell = ReadSimpleBarControl(&Name, &Vertical); 03924 } 03925 } 03926 else 03927 { 03928 // Read in both controls as one 03929 pos = Name.FindNextChar(B); 03930 Name.Remove(0, pos+2); 03931 03932 AllIsWell = ReadSimpleBarControl(&Name, &Horizontal); 03933 03934 // if horz and vert defs are the same, make vert = horz version. 03935 Vertical = Horizontal; 03936 } 03937 } 03938 catch( ... ) 03939 { 03940 // An exception has been thrown which means 03941 // we failed to parse this string, so simply report failure 03942 AllIsWell = FALSE; 03943 } 03944 03945 // Switch off the exception state finally, (and of course pop it)! 03946 StringBase::DisableExceptionHandler(); 03947 03948 return AllIsWell; 03949 }
|
|
Reads a tokenized form of the control from the given file.
Implements BarItem. Definition at line 4094 of file bars.cpp. 04095 { 04096 TokenIndex Token = TOKEN_NONE; 04097 const TCHAR* TokenBuf = file.GetTokenBuf(); 04098 BOOL ok; 04099 04100 ok = file.GetSimpleToken(); // Read the first token 04101 if (ok) 04102 { 04103 Token = FindToken(TokenBuf); 04104 // Check that next token defines either the horz or both versions of the control 04105 ok = ((Token == TOKEN_BAR_CONTROL_HORZ) || (Token == TOKEN_BAR_CONTROL_BOTH)); 04106 if (!ok) TRACE( _T("Expected a '%s' or a '%s', but found '%s'."),TokenTable[TOKEN_BAR_CONTROL_HORZ].Token,TokenTable[TOKEN_BAR_CONTROL_BOTH].Token,TokenBuf); 04107 04108 if (ok) ok = ReadSimpleBarControl(file,&Horizontal); 04109 } 04110 04111 if (ok && Token == TOKEN_BAR_CONTROL_BOTH) 04112 // if horz and vert defs are the same, make vert = horz version. 04113 Vertical = Horizontal; 04114 else if (ok) 04115 { 04116 // otherwise, read the vert definition 04117 ok = file.GetSimpleToken(); 04118 if (ok) 04119 { 04120 Token = FindToken(TokenBuf); 04121 ok = (Token == TOKEN_BAR_CONTROL_VERT); 04122 if (!ok) TRACE( _T("Expected a '%s', but found '%s'."),TokenTable[TOKEN_BAR_CONTROL_VERT].Token,TokenBuf); 04123 04124 if (ok) ok = ReadSimpleBarControl(file,&Vertical); 04125 } 04126 } 04127 04128 if (!ok) 04129 { 04130 // If something when wrong, tell the debug dudes and give as much info as possible 04131 //ENSURE(FALSE,"Error reading a bar control. See TRACE output for details"); 04132 TRACE( _T("\n\nError reading a bar control:\n")); 04133 TRACE( _T(" Token buffer = %s\n"),TokenBuf); 04134 TRACE( _T(" Line buffer = %s\n"),file.GetLineBuf()); 04135 } 04136 04137 return (ok); 04138 }
|
|
Reads a tokenized form of the simple bar control from the given file.
Definition at line 4156 of file bars.cpp. 04157 { 04158 const TCHAR* TokenBuf = file.GetTokenBuf(); 04159 BOOL ok; 04160 04161 ok = file.GetSimpleToken(); 04162 04163 if (ok) 04164 { 04165 // The first token is either a string describing the op descriptor or 04166 // the ID for the bubble help message 04167 LexTokenType TokenType = file.GetTokenType(); 04168 04169 switch (TokenType) 04170 { 04171 case TOKEN_STRING : 04172 pSBC->pOpDesc = OpDescriptor::FindOpDescriptor( const_cast<TCHAR*>(TokenBuf) ); 04173 pSBC->BubbleID = _R(IDBBL_NOOP); 04174 pSBC->StatusID = 0; 04175 04176 if ((TokenBuf[0] != 0) && (pSBC->pOpDesc == NULL)) 04177 { 04178 // If there is an op desc token string, but no op desc was found, fail 04179 TRACE( _T("Can't find op descriptor! OpToken of missing op = %s\n"),TokenBuf); 04180 ok = FALSE; 04181 } 04182 04183 break; 04184 04185 case TOKEN_NORMAL : 04186 pSBC->pOpDesc = NULL; // No op descriptor associated with this control 04187 04188 // Read the bubble and status bar text IDs 04189 ok = (camSscanf(TokenBuf, _T("%li"),&pSBC->BubbleID) == 1); 04190 if (!ok) TRACE( _T("Expected a bubble ID, but got '%s'\n"),TokenBuf); 04191 04192 if (ok) ok = file.GetSimpleToken(); 04193 if (ok) 04194 { 04195 ok = (camSscanf(TokenBuf,_T("%li"),&pSBC->StatusID) == 1); 04196 if (!ok) TRACE( _T("Expected a status ID, but got '%s'\n"),TokenBuf); 04197 } 04198 04199 break; 04200 04201 default : 04202 ok = FALSE; // What kind of token is this? Get out of here! 04203 TRACE( _T("Don't recognise this token '%s'. Wrong type\n"),TokenBuf); 04204 break; 04205 } 04206 04207 // The next three tokens are the tool ID, resource ID, and the control ID 04208 if (ok) ok = file.GetSimpleToken(); 04209 if (ok) 04210 { 04211 // Interpret the next token as an INT32 (dec,hex, or oct) 04212 ok = (camSscanf(TokenBuf, _T("%li"),&pSBC->BarCtrlInfo.ToolID) == 1); 04213 if (!ok) TRACE( _T("Expected a tool ID, but got '%s'\n"),TokenBuf); 04214 04215 if (ok) ok = file.GetSimpleToken(); 04216 if (ok) 04217 { 04218 // Interpret the next token as an INT32 (dec,hex, or oct) 04219 ok = (camSscanf(TokenBuf, _T("%li"),&pSBC->BarCtrlInfo.ResourceID) == 1); 04220 if (!ok) TRACE( _T("Expected a resource ID, but got '%s'\n"),TokenBuf); 04221 04222 if (ok) ok = file.GetSimpleToken(); 04223 if (ok) 04224 { 04225 // Interpret the next token as an INT32 (dec,hex, or oct) 04226 ok = (camSscanf(TokenBuf,_T("%li"),&pSBC->BarCtrlInfo.ControlID) == 1); 04227 if (!ok) TRACE( _T("Expected a control ID, but got '%s'\n"),TokenBuf); 04228 } 04229 } 04230 } 04231 } 04232 04233 return ok; 04234 }
|
|
Reads a tokenized form of the simple bar control from the given string.
Definition at line 3967 of file bars.cpp. 03968 { 03969 ERROR2IF(pString == NULL || pSBC == NULL,FALSE,"ReadSimpleBarControl given null parameters!"); 03970 03971 String_256 OpName; 03972 INT32 pos = 0; 03973 // This text must not be internationalised 03974 const TCHAR QUOTES = TEXT('"'); 03975 03976 // See if a string follows or if a bubble and status ids follow 03977 if ((*pString)[pos] == QUOTES) 03978 { 03979 // Go to the first quote of the first string 03980 pos = pString->FindNextChar(QUOTES, pos); 03981 pString->Remove(0, pos+1); 03982 03983 // Now find the last quote of the first string 03984 pos = pString->FindNextChar(QUOTES); 03985 // Read the operation name into OpName 03986 pString->Left(&OpName, pos); 03987 pString->Remove(0, pos+1); 03988 pos = 0; 03989 03990 // Try and find the OpDescriptor that should be in the system 03991 pSBC->pOpDesc = OpDescriptor::FindOpDescriptor(OpName); 03992 pSBC->BubbleID = _R(IDBBL_NOOP); 03993 pSBC->StatusID = 0; 03994 if ((OpName.Length() > 0) && (pSBC->pOpDesc == NULL)) 03995 { 03996 // If there is an op desc token string, but no op desc was found, fail 03997 TRACE( _T("Can't find op descriptor! OpToken of missing op = %s\n"),(TCHAR*)OpName); 03998 return FALSE; 03999 } 04000 } 04001 else 04002 { 04003 // Its as simple control 04004 // No op descriptor associated with this control 04005 pSBC->pOpDesc = NULL; 04006 04007 // Read the bubble and status bar text IDs 04008 pSBC->BubbleID = pString->ConvertToInteger(pos); 04009 pSBC->StatusID = pString->ConvertToInteger(pos); 04010 pString->Remove(0,pos); 04011 pos = 0; 04012 } 04013 04014 // The next three tokens are the tool ID, resource ID, and the control ID 04015 pSBC->BarCtrlInfo.ToolID = pString->ConvertToInteger(pos); 04016 pSBC->BarCtrlInfo.ResourceID = pString->ConvertToInteger(pos); 04017 pSBC->BarCtrlInfo.ControlID = pString->ConvertToInteger(pos); 04018 pString->Remove(0,pos); 04019 pos = 0; 04020 04021 return TRUE; 04022 }
|
|
Definition at line 284 of file bars.h. 00284 {Enabled = enabled;}
|
|
Sets the info regarding the horizontal version of this control.
Definition at line 3622 of file bars.cpp. 03623 { 03624 SetOpDesc(&Horizontal,pOpDesc); 03625 }
|
|
Sets the info for this control using the given op desc It's intended that this be called when a bar control is added to a bar via the toolbar dialogue interface.
Definition at line 3666 of file bars.cpp. 03667 { 03668 // Get ptr to default control info 03669 const BarControlInfo* pBarCtrlInfo = pOpDesc->GetBarControlInfo(); 03670 03671 // Copy the default info stored in the OpDesc bar ctrl info into 03672 // this bar control. 03673 pSimpleBC->BarCtrlInfo.ResourceID = pBarCtrlInfo->ResourceID; 03674 pSimpleBC->BarCtrlInfo.ControlID = pBarCtrlInfo->ControlID; 03675 pSimpleBC->BarCtrlInfo.ToolID = pBarCtrlInfo->ToolID; 03676 03677 // Copy ptr to the OpDesc. 03678 pSimpleBC->pOpDesc = pOpDesc; 03679 }
|
|
Definition at line 280 of file bars.h. 00280 {UniqueGadgetID = UniqueGadget;}
|
|
Sets the info regarding the vertical version of this control.
Definition at line 3642 of file bars.cpp.
|
|
Definition at line 285 of file bars.h. 00285 {Visible = visible;}
|
|
Implements BarItem. Definition at line 3801 of file bars.cpp. 03802 { 03803 ERROR2IF(pString == NULL,FALSE,"Write given null string"); 03804 03805 BOOL ok = TRUE; 03806 TCHAR buf[10]; 03807 03808 // Add that its a bar control 03809 *pString += TokenTable[TOKEN_BAR_CONTROL].Token; 03810 *pString += _T(" "); 03811 03812 // save out the horizontal state starting with the horizontal token 03813 *pString += TokenTable[TOKEN_BAR_CONTROL_HORZ].Token; 03814 *pString += _T(" "); 03815 03816 if (Horizontal.pOpDesc) 03817 { 03818 *pString += wxT(QUOTE); 03819 *pString += Horizontal.pOpDesc->Token; 03820 *pString += wxT(QUOTE) wxT(" "); 03821 } 03822 else 03823 { 03824 camSnprintf(buf, 9, TEXT("%d "), Horizontal.BubbleID); 03825 *pString += buf; 03826 camSnprintf(buf, 9, TEXT("%d "), Horizontal.StatusID); 03827 *pString += buf; 03828 } 03829 camSnprintf(buf, 9, TEXT("%d "), Horizontal.BarCtrlInfo.ToolID); 03830 *pString += buf; 03831 camSnprintf(buf, 9, TEXT("%d "), Horizontal.BarCtrlInfo.ResourceID); 03832 *pString += buf; 03833 camSnprintf(buf, 9, TEXT("%d "), Horizontal.BarCtrlInfo.ControlID); 03834 *pString += buf; 03835 03836 *pString += TokenTable[TOKEN_BAR_CONTROL_VERT].Token; 03837 *pString += _T(" "); 03838 if(Vertical.pOpDesc) 03839 { 03840 *pString += wxT(QUOTE); 03841 *pString += Vertical.pOpDesc->Token; 03842 *pString += wxT(QUOTE) wxT(" "); 03843 } 03844 else 03845 { 03846 camSnprintf(buf, 9, TEXT("%d "), Vertical.BubbleID); 03847 *pString += buf; 03848 camSnprintf(buf, 9, TEXT("%d "), Vertical.StatusID); 03849 *pString += buf; 03850 } 03851 camSnprintf(buf, 9, TEXT("%d "), Vertical.BarCtrlInfo.ToolID); 03852 *pString += buf; 03853 camSnprintf(buf, 9, TEXT("%d "), Vertical.BarCtrlInfo.ResourceID); 03854 *pString += buf; 03855 camSnprintf(buf, 9, TEXT("%d "), Vertical.BarCtrlInfo.ControlID); 03856 *pString += buf; 03857 03858 return ok; 03859 }
|
|
Writes a tokenized form of the control to the given file.
Implements BarItem. Definition at line 4039 of file bars.cpp. 04040 { 04041 BOOL ok = TRUE; 04042 04043 if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_CONTROL].Token); 04044 04045 if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_CONTROL_HORZ].Token); 04046 04047 if(Horizontal.pOpDesc) 04048 { 04049 if (ok) ok = file.PutString(Horizontal.pOpDesc->Token); 04050 } 04051 else 04052 { 04053 if (ok) ok = file.PutToken(Horizontal.BubbleID); 04054 if (ok) ok = file.PutToken(Horizontal.StatusID); 04055 } 04056 if (ok) ok = file.PutToken(Horizontal.BarCtrlInfo.ToolID); 04057 if (ok) ok = file.PutToken(Horizontal.BarCtrlInfo.ResourceID); 04058 if (ok) ok = file.PutToken(Horizontal.BarCtrlInfo.ControlID); 04059 04060 if (ok) ok = file.PutToken(TokenTable[TOKEN_BAR_CONTROL_VERT].Token); 04061 if(Vertical.pOpDesc) 04062 { 04063 if (ok) ok = file.PutString(Vertical.pOpDesc->Token); 04064 } 04065 else 04066 { 04067 if (ok) ok = file.PutToken(Vertical.BubbleID); 04068 if (ok) ok = file.PutToken(Vertical.StatusID); 04069 } 04070 if (ok) ok = file.PutToken(Vertical.BarCtrlInfo.ToolID); 04071 if (ok) ok = file.PutToken(Vertical.BarCtrlInfo.ResourceID); 04072 if (ok) ok = file.PutToken(Vertical.BarCtrlInfo.ControlID); 04073 return (ok); 04074 }
|
|
|
|
|
|
|
|
|
|
|