BarTable Class Reference

Provide an array of window handles for all the existing Camelot bars. This enables us to get bubble help to behave correctly, i.e. when the cursor is over the bar, the bubble help goes away, but the delay timer for bubble help is not restarted. More...

Inheritance diagram for BarTable:

SimpleCCObject List of all members.

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

Detailed Description

Provide an array of window handles for all the existing Camelot bars. This enables us to get bubble help to behave correctly, i.e. when the cursor is over the bar, the bubble help goes away, but the delay timer for bubble help is not restarted.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/04/94
See also:
ControlHelper

Definition at line 148 of file ctrlhelp.cpp.


Member Enumeration Documentation

anonymous enum [private]
 

Enumerator:
NotFound 
EmptySlot 
Granularity 
InitialSize 

Definition at line 164 of file ctrlhelp.cpp.

00165     {
00166         NotFound = -1,
00167         EmptySlot = 0,
00168         Granularity = 5,
00169         InitialSize = 10
00170     };


Constructor & Destructor Documentation

BarTable::BarTable  ) 
 

Construct the bar table object.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/94
See also:
BarTable::Init

Definition at line 187 of file ctrlhelp.cpp.

00188 {
00189     // No table data yet.
00190     Table = NULL;
00191     TableSize = 0;
00192 }

BarTable::~BarTable  ) 
 

Destroy a BarTable object - frees up all memory used by the table data.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/94
See also:
BarTable::Init

Definition at line 205 of file ctrlhelp.cpp.

00206 {
00207     // Free up the table data.
00208     CCFree((void*)Table);
00209 }


Member Function Documentation

BOOL BarTable::AddBar wxWindow *  Window  ) 
 

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.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/94
Parameters:
Window - the handle of the bar. [INPUTS]
Returns:
TRUE if the bar was added to the table successully; FALSE if not.

Errors: Out of memory, Bar already exists in the table (debug builds only).

See also:
BarTable::DeleteBar; BarTable::FindBar

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 }

BOOL BarTable::ChangeBar wxWindow *  Old,
wxWindow *  New
 

Inform the table that a bar has been deleted and recreated with a new window handle.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/04/94
Parameters:
Old - the old window handle of the bar. [INPUTS] New - the new window handle of the bar.
Returns:
TRUE if the bar was changed successfully; FALSE if not.

Errors: The bar could not be found.

See also:
BarTable::AddBar; BarTable::DeleteBar

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 }

BOOL BarTable::DeleteBar wxWindow *  Window  ) 
 

Remove the control from the table of subclassed controls.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/94
Parameters:
Window - the handle of the control to remove. [INPUTS]
Returns:
TRUE if the control was removed ok; FALSE if the control could not be found in the table.

Errors: Control's window handle was not found in the table (ENSUREs in debug builds).

See also:
BarTable::AddControl; BarTable::FindControl; ControlHelper; ControlEntry

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 }

INT32 BarTable::FindBarIndex wxWindow *  Window  )  [private]
 

Given the window handle of a control, return the offset into the table array of its record.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/94
Parameters:
Window - the handle of the control to search for. [INPUTS]
Returns:
The index into the Table array of the control's record, or BarTable::NotFound if the control is not registered in the table.

Errors: Not found.

See also:
BarTable::FindControl; BarTable::DeleteControl

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 }

BOOL BarTable::Init void   ) 
 

Allocate and initialise the table of bar entries.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/04/94
Returns:
TRUE if successful; FALSE if not.

Errors: Out of memory.

See also:
BarTable

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 }

BOOL BarTable::IsABar wxWindow *  Window  ) 
 

Find out if a given window handle is the handle of a Camelot bar, as recorded in this BarTable object.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/04/94
Parameters:
Window - the window handle to check. [INPUTS]
Returns:
TRUE if this window handle is registered as a Camelot bar; FALSE if not.
See also:
ControlHelper

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 }


Member Data Documentation

wxWindow** BarTable::Table [private]
 

Definition at line 172 of file ctrlhelp.cpp.

INT32 BarTable::TableSize [private]
 

Definition at line 173 of file ctrlhelp.cpp.


The documentation for this class was generated from the following file:
Generated on Sat Nov 10 03:50:49 2007 for Camelot by  doxygen 1.4.4