Inheritance diagram for BarTable:
Public Member Functions | |
BarTable () | |
Construct the bar table object. | |
~BarTable () | |
Destroy a BarTable object - frees up all memory used by the table data. | |
BOOL | Init () |
Allocate and initialise the table of bar entries. | |
BOOL | AddBar (wxWindow *) |
Add a barhandle to the table, using the data passed in. The table will expand to accomodate the new bar if necessary and if possible. | |
BOOL | DeleteBar (wxWindow *) |
Remove the control from the table of subclassed controls. | |
BOOL | ChangeBar (wxWindow *, wxWindow *) |
Inform the table that a bar has been deleted and recreated with a new window handle. | |
BOOL | IsABar (wxWindow *) |
Find out if a given window handle is the handle of a Camelot bar, as recorded in this BarTable object. | |
Private Types | |
enum | { NotFound = -1, EmptySlot = 0, Granularity = 5, InitialSize = 10 } |
Private Member Functions | |
INT32 | FindBarIndex (wxWindow *) |
Given the window handle of a control, return the offset into the table array of its record. | |
Private Attributes | |
wxWindow ** | Table |
INT32 | TableSize |
Definition at line 148 of file ctrlhelp.cpp.
|
Definition at line 164 of file ctrlhelp.cpp. 00165 { 00166 NotFound = -1, 00167 EmptySlot = 0, 00168 Granularity = 5, 00169 InitialSize = 10 00170 };
|
|
Construct the bar table object.
Definition at line 187 of file ctrlhelp.cpp.
|
|
Destroy a BarTable object - frees up all memory used by the table data.
Definition at line 205 of file ctrlhelp.cpp.
|
|
Add a barhandle to the table, using the data passed in. The table will expand to accomodate the new bar if necessary and if possible.
Definition at line 262 of file ctrlhelp.cpp. 00263 { 00264 // Basic sanity checks. 00265 ENSURE(Window != NULL, "NULL window handle in BarTable::AddBar"); 00266 if (Window == NULL ) 00267 return FALSE; 00268 ENSURE(FindBarIndex(Window) == BarTable::NotFound, "Bar already exists in BarTable::AddBar"); 00269 00270 INT32 i = 0; 00271 while ((i < TableSize) && (Table[i] != EMPTY_SLOT)) 00272 i++; 00273 00274 if (i >= TableSize) 00275 { 00276 // No free slots - extend the table. 00277 INT32 NewTableSize = TableSize + BarTable::Granularity; 00278 wxWindow* *NewTable = (wxWindow* *) CCRealloc((void*)Table, NewTableSize * sizeof(wxWindow*)); 00279 if (NewTable == NULL) 00280 return FALSE; 00281 00282 // Table extended ok - point 'i' at the first free slot, and update table variables. 00283 i = TableSize; 00284 Table = NewTable; 00285 TableSize = NewTableSize; 00286 00287 for (INT32 j=i+1;j<TableSize;j++) 00288 Table[j] = EMPTY_SLOT; 00289 } 00290 00291 // If we've got this far, 'i' points at a valid free slot in the table. 00292 Table[i] = Window; 00293 00294 // Everything worked 00295 return TRUE; 00296 }
|
|
Inform the table that a bar has been deleted and recreated with a new window handle.
Definition at line 354 of file ctrlhelp.cpp. 00355 { 00356 // Basic sanity checks 00357 ENSURE((Old != NULL) && (New != NULL), "NULL Window handle in BarTable::ChangeBar!"); 00358 if ((Old == NULL) || (New == NULL)) 00359 return FALSE; 00360 00361 // Search for the specified bar. 00362 INT32 i = FindBarIndex(Old); 00363 00364 ENSURE(i != BarTable::NotFound, "Control not found in BarTable::ChangeBar"); 00365 00366 if (i == BarTable::NotFound) 00367 // Unable to find any record of the bar 00368 return FALSE; 00369 00370 // Found the bar - update the window handle. 00371 Table[i] = New; 00372 00373 // Return success 00374 return TRUE; 00375 }
|
|
Remove the control from the table of subclassed controls.
Definition at line 314 of file ctrlhelp.cpp. 00315 { 00316 // Basic sanity checks 00317 ENSURE(Window != 0, "NULL Window handle in BarTable::DeleteBar!"); 00318 if (Window == 0) 00319 return FALSE; 00320 00321 // Search for the specified bar. 00322 INT32 i = FindBarIndex(Window); 00323 00324 ENSURE(i != BarTable::NotFound, "Control not found in BarTable::DeleteBar"); 00325 00326 if (i == BarTable::NotFound) 00327 // Unable to find any record of the bar 00328 return FALSE; 00329 00330 // Found the bar - delete it 00331 Table[i] = EMPTY_SLOT; 00332 00333 // Return success 00334 return TRUE; 00335 }
|
|
Given the window handle of a control, return the offset into the table array of its record.
Definition at line 418 of file ctrlhelp.cpp. 00419 { 00420 // Scane the table for this entry 00421 INT32 i = 0; 00422 while ((i < TableSize) && (Table[i] != Window)) 00423 i++; 00424 00425 // Did we find it? 00426 if (Table[i] != Window) 00427 // No - inform caller of failure. 00428 return BarTable::NotFound; 00429 00430 // Yes, success 00431 return i; 00432 }
|
|
Allocate and initialise the table of bar entries.
Reimplemented from SimpleCCObject. Definition at line 225 of file ctrlhelp.cpp. 00226 { 00227 // Try to get some space for our table. 00228 Table = (wxWindow**) CCMalloc(BarTable::InitialSize * sizeof(wxWindow*)); 00229 if (Table == NULL) 00230 return FALSE; 00231 00232 // Initialise the table 00233 for (INT32 i = 0; i < BarTable::InitialSize; i++) 00234 { 00235 // No control registered in this entry yet 00236 Table[i] = EMPTY_SLOT; 00237 } 00238 00239 // Update the table size 00240 TableSize = BarTable::InitialSize; 00241 00242 // Success! 00243 return TRUE; 00244 }
|
|
Find out if a given window handle is the handle of a Camelot bar, as recorded in this BarTable object.
Definition at line 393 of file ctrlhelp.cpp. 00394 { 00395 ENSURE(Window != NULL, "NULL Window in BarTable::IsABar"); 00396 if (Window == NULL) 00397 return FALSE; 00398 00399 return (FindBarIndex(Window) != BarTable::NotFound); 00400 }
|
|
Definition at line 172 of file ctrlhelp.cpp. |
|
Definition at line 173 of file ctrlhelp.cpp. |