Public Member Functions | |
HandleTable (MetaFileFilter *) | |
Initialises the HandleTable. The table initially contains no entries. | |
~HandleTable () | |
Deinitialises a handle table; deallocates the handle table. | |
BOOL | CreatePen (LOGPEN_16 *) |
Create a handle for the specified pen in the HandleTable, and store the pen information in this. | |
BOOL | CreateBrush (LOGBRUSH_16 *) |
Create a handle for the specified brush in the HandleTable, and store the brush information in this. | |
BOOL | CreatePalette (LOGPALETTE_16 *) |
Creates a Palette object ready for use. | |
BOOL | CreatePatternBrush (WORD *) |
Creates a PatternBrush object ready for use. | |
BOOL | CreateFontIndirect (LOGFONT_16 *) |
Creates a Font object ready for use. | |
BOOL | CreateRegion (WORD *) |
Creates a Region object ready for use. | |
BOOL | SelectObject (INT32 Index) |
Mimic the selection of a GDI object. This function will update the relevant status variables in the associated MetaFileFilter object. | |
BOOL | DeleteObject (INT32 Index) |
Deletes a handle from the Handle table. The index of this handle should no longer be used (unless, of course, it is reallocated to a new handle). | |
Private Member Functions | |
INT32 | FindFreeSlot () |
Find the index of the first free slot available in the handle table. If no free handles are found, the table is expanded and the index of the first new slot is returned. If it is not possible to expand the table (out of memerory) then BAD_SLOT is returned. | |
Private Attributes | |
MetaFileFilter * | Context |
HandleRecord * | Handles |
INT32 | TableSize |
Definition at line 260 of file metafilt.cpp.
|
Initialises the HandleTable. The table initially contains no entries.
Definition at line 302 of file metafilt.cpp.
|
|
Deinitialises a handle table; deallocates the handle table.
Definition at line 320 of file metafilt.cpp.
|
|
Create a handle for the specified brush in the HandleTable, and store the brush information in this.
Definition at line 477 of file metafilt.cpp. 00478 { 00479 INT32 Style = pBrush->lbStyle; 00480 COLORREF Col = (COLORREF) pBrush->lbColor; 00481 00482 // Get a new slot to put this pen in 00483 INT32 Slot = FindFreeSlot(); 00484 00485 if (Slot == BAD_SLOT) 00486 // Could not create this pen 00487 return FALSE; 00488 00489 Handles[Slot].Type = HANDLE_BRUSH; 00490 00491 switch (Style) 00492 { 00493 case BS_SOLID: 00494 Handles[Slot].Colour = DocColour(GetRValue(Col), GetGValue(Col), GetBValue(Col)); 00495 break; 00496 00497 case BS_NULL: 00498 Handles[Slot].Colour = DocColour(COLOUR_TRANS); 00499 break; 00500 00501 default: 00502 ENSURE(FALSE, "Unknown brush style in metafile!"); 00503 ERROR(_R(IDT_BAD_METAFILE), FALSE); 00504 } 00505 00506 // All ok 00507 return TRUE; 00508 }
|
|
Creates a Font object ready for use.
Definition at line 576 of file metafilt.cpp. 00577 { 00578 // Get a new slot to put this pen in 00579 INT32 Slot = FindFreeSlot(); 00580 00581 // Could not create this Palette 00582 if (Slot == BAD_SLOT) 00583 return FALSE; 00584 00585 // Say what this is 00586 Handles[Slot].Type = HANDLE_FONTINDIRECT; 00587 Handles[Slot].pFont = pNewFont; 00588 00589 // return Happy 00590 return TRUE; 00591 }
|
|
Creates a Palette object ready for use.
Definition at line 521 of file metafilt.cpp. 00522 { 00523 // Get a new slot to put this pen in 00524 INT32 Slot = FindFreeSlot(); 00525 00526 // Could not create this Palette 00527 if (Slot == BAD_SLOT) 00528 return FALSE; 00529 00530 // Say what this is 00531 Handles[Slot].Type = HANDLE_PALETTE; 00532 00533 // return Happy 00534 return TRUE; 00535 }
|
|
Creates a PatternBrush object ready for use.
Definition at line 548 of file metafilt.cpp. 00549 { 00550 // Get a new slot to put this pen in 00551 INT32 Slot = FindFreeSlot(); 00552 00553 // Could not create this Palette 00554 if (Slot == BAD_SLOT) 00555 return FALSE; 00556 00557 // Say what this is 00558 Handles[Slot].Type = HANDLE_PATTERNBRUSH; 00559 00560 // return Happy 00561 return TRUE; 00562 }
|
|
Create a handle for the specified pen in the HandleTable, and store the pen information in this.
Definition at line 422 of file metafilt.cpp. 00423 { 00424 INT32 Style = pPen->lopnStyle; 00425 COLORREF Col = (COLORREF) pPen->lopnColor; 00426 00427 // Get a new slot to put this pen in 00428 INT32 Slot = FindFreeSlot(); 00429 00430 if (Slot == BAD_SLOT) 00431 // Could not create this pen 00432 return FALSE; 00433 00434 Handles[Slot].Type = HANDLE_PEN; 00435 00436 switch (Style) 00437 { 00438 case PS_SOLID: 00439 case PS_INSIDEFRAME: 00440 Handles[Slot].Colour = DocColour(GetRValue(Col), GetGValue(Col), GetBValue(Col)); 00441 break; 00442 00443 case PS_NULL: 00444 Handles[Slot].Colour = DocColour(COLOUR_TRANS); 00445 break; 00446 00447 default: 00448 ENSURE(FALSE, "Unknown pen style in metafile!"); 00449 ERROR(_R(IDT_BAD_METAFILE), FALSE); 00450 } 00451 00452 // Scale pen width to document coordinates. 00453 DocCoord PenSize(pPen->lopnWidth.x, 0); 00454 Context->ScaleCoord(&PenSize); 00455 Handles[Slot].PenWidth = PenSize.x; 00456 00457 // All ok 00458 return TRUE; 00459 }
|
|
Creates a Region object ready for use.
Definition at line 604 of file metafilt.cpp. 00605 { 00606 // Get a new slot to put this pen in 00607 INT32 Slot = FindFreeSlot(); 00608 00609 // Could not create this Palette 00610 if (Slot == BAD_SLOT) 00611 return FALSE; 00612 00613 // Say what this is 00614 Handles[Slot].Type = HANDLE_REGION; 00615 00616 // return Happy 00617 return TRUE; 00618 }
|
|
Deletes a handle from the Handle table. The index of this handle should no longer be used (unless, of course, it is reallocated to a new handle).
Definition at line 701 of file metafilt.cpp. 00702 { 00703 // Sanity check 00704 if ((Index < 0) || (Index >= TableSize)) 00705 { 00706 // Out of range index 00707 if (IsUserName("Rik")) 00708 TRACE( _T("Tried to delete out of range object\n")); 00709 return FALSE; 00710 } 00711 00712 // Try to select the object. 00713 switch (Handles[Index].Type) 00714 { 00715 case HANDLE_NONE: 00716 // No such object 00717 if (IsUserName("Rik")) 00718 TRACE( _T("Tried to delete non-existent object\n")); 00719 return FALSE; 00720 00721 case HANDLE_PEN: 00722 case HANDLE_BRUSH: 00723 case HANDLE_PALETTE: 00724 case HANDLE_PATTERNBRUSH: 00725 case HANDLE_FONTINDIRECT: 00726 case HANDLE_REGION: 00727 Handles[Index].Type = HANDLE_NONE; 00728 break; 00729 00730 default: 00731 ENSURE(FALSE, "Bad metafile handle type!"); 00732 ERROR(_R(IDT_BAD_METAFILE), FALSE); 00733 } 00734 00735 // To get here we must have deleted the object ok 00736 return TRUE; 00737 }
|
|
Find the index of the first free slot available in the handle table. If no free handles are found, the table is expanded and the index of the first new slot is returned. If it is not possible to expand the table (out of memerory) then BAD_SLOT is returned.
Definition at line 354 of file metafilt.cpp. 00355 { 00356 INT32 Slot; 00357 00358 // Search the existing table for blanks 00359 for (Slot = 0; Slot < TableSize; Slot++) 00360 { 00361 if (Handles[Slot].Type == HANDLE_NONE) 00362 return Slot; 00363 } 00364 00365 // Didn't find a free slot - get some more memory and return the first slot we get. 00366 00367 INT32 NewTableSize = TableSize + TableGranularity; 00368 00369 // If no slots yet, then allocate a table, otherwise expand the existing table 00370 HandleRecord *NewHandles; 00371 if (Handles == NULL) 00372 NewHandles = (HandleRecord *) CCMalloc(NewTableSize * sizeof(HandleRecord)); 00373 else 00374 NewHandles = (HandleRecord *) CCRealloc(Handles, NewTableSize * sizeof(HandleRecord)); 00375 00376 // Did that work? 00377 if (NewHandles == NULL) 00378 { 00379 // No more memory available, but error state set by ccmalloc 00380 return BAD_SLOT; 00381 } 00382 00383 // Initialise the new slots 00384 for (Slot = TableSize; Slot < NewTableSize; Slot++) 00385 { 00386 NewHandles[Slot].Type = HANDLE_NONE; 00387 00388 // This bizarre syntax of 'new' allows us to call the constructor for an object 00389 // that has already been allocated. We need to do this otherwise all the 00390 // DocColour objects in the handle table are not initialised. 00391 // The constructors are not called because we just CCMalloc() the block of memory, 00392 // because we want to be able to resize the block (using CCRealloc). 00393 new(&NewHandles[Slot].Colour) DocColour; 00394 } 00395 00396 // Remember the first slot 00397 Slot = TableSize; 00398 00399 // Update handle table variables 00400 Handles = NewHandles; 00401 TableSize = NewTableSize; 00402 00403 // Return the first new slot 00404 return Slot; 00405 }
|
|
Mimic the selection of a GDI object. This function will update the relevant status variables in the associated MetaFileFilter object.
Definition at line 635 of file metafilt.cpp. 00636 { 00637 // Sanity check 00638 if ((Index < 0) || (Index >= TableSize)) 00639 { 00640 // Out of range index 00641 if (IsUserName("Rik")) 00642 TRACE( _T("Tried to select out of range object\n")); 00643 ERROR(_R(IDT_BAD_METAFILE), FALSE); 00644 } 00645 00646 // Try to select the object. 00647 switch (Handles[Index].Type) 00648 { 00649 case HANDLE_NONE: 00650 // No such object 00651 if (IsUserName("Rik")) 00652 TRACE( _T("Tried to select non-existent object\n")); 00653 return FALSE; 00654 00655 case HANDLE_PEN: 00656 Context->SetLineColour(Handles[Index].Colour); 00657 Context->SetLineWidth(Handles[Index].PenWidth); 00658 break; 00659 00660 case HANDLE_BRUSH: 00661 Context->SetFillColour(Handles[Index].Colour); 00662 break; 00663 00664 case HANDLE_PALETTE: 00665 break; 00666 00667 case HANDLE_PATTERNBRUSH: 00668 break; 00669 00670 case HANDLE_FONTINDIRECT: 00671 Context->SetLogicalFont(Handles[Index].pFont); 00672 break; 00673 00674 case HANDLE_REGION: 00675 break; 00676 00677 default: 00678 ENSURE(FALSE, "Bad metafile handle type!"); 00679 ERROR(_R(IDT_BAD_METAFILE), FALSE); 00680 } 00681 00682 // To get here we must have selected the object ok 00683 return TRUE; 00684 }
|
|
Definition at line 282 of file metafilt.cpp. |
|
Definition at line 285 of file metafilt.cpp. |
|
Definition at line 288 of file metafilt.cpp. |