[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


ICodeWarriorDocument

This interface allows you to do window management, and change the size and position of windows. Other interfaces that may be useful include ICodeWarriorProjectDocument and ICodeWarriorTextDocument. For text engine work, you'll use ICodeWarriorTextEngine.

You will probably also want to utilize the interface called ICodeWarriorDocumentCollection. For example, you would use the Item() method of ICodeWarriorDocumentCollection to get a document.

For an example illustrating the use of some of these methods, refer to Listing 3.19.

The methods documented here include:


Getting the Active Document - Active Document

This allows you to determine whether you are working with the active document (the currently-selected document in the foreground).


Arguments

None


Return Value

VARIANT_BOOL* pval - true or false, whether this is the active document.


Activating a Document - Activate

This allows you to activate the document (the currently-selected document in the foreground).


Arguments

None


Return Value

None


Checking for Document Changes - Dirty

This allows you to check for whether the document has changed and needs to be saved. Refer to "Saving a Document - Save" to learn how to save a document.


Arguments

None


Return Value

VARIANT_BOOL* pval - true or false, whether the document is dirty or not.


Getting a Document Name - Name

Allows you to get a document's name.


Arguments

None


Return Value

BSTR* pval - the document name.


Checking Read-Only Status - ReadOnly

Allows to see if a document is marked read-only. Refer to "ICodeWarriorVCSState" and "ICodeWarriorVersionControl" for related discussion.


Arguments

None


Return Value

VARIANT_BOOL* pval - true or false, whether the document is marked read-only (non-modifiable) or not.


Getting X Position - XPos

Get the X-axis window position.


Arguments

None


Return Value

int* pval - an integer giving the X-axis window coordinate of the document's window.


Setting X Position - XPos

Set the X-axis document position.


Arguments

 

Argument
Functionality
int pval  
The X-axis value to position the document window.  

ICodeWarriorDocument.XPos Arguments:

Return Value

None


Getting Y Position - YPos

Get the Y-axis window position.


Arguments

None


Return Value

int* pval - an integer giving the X-axis window coordinate of the document's window.


Setting Y Position - YPos

Set the Y-axis document position.


Arguments

 

Argument
Functionality
int pval  
The X-axis value to position the document window.  

ICodeWarriorDocument.YPos Arguments:

Return Value

None


Getting Width - Width

Get the document's window width (size along the X-axis).


Arguments

None


Return Value

int* pval - the width of the window.


Setting Width - Width

Sets the document window's width.

Arguments

 

Argument
Functionality
int pval  
The width to set for the document window.  

ICodeWarriorDocument.Width Arguments:

Return Value

None


Getting Height - Height

Get the height of the document's window.


Arguments

None


Return Value

int* pval - the height of the document's window.


Setting Height - Height

Set the height of the document's window.


Arguments

 

Argument
Functionality
int pval  
The height to set for the document's window.  

ICodeWarriorDocument.Height Arguments:

Return Value

None


Checking for Visibility - Visible

Checking to see whether a document's window is currently visible or not.


Arguments

None


Return Value

VARIANT_BOOL* pval - true or false, whether the window is visible or not.


Setting Visibility - Visible

Sets the visibility of a document's window.


Arguments

 

Argument
Functionality
VARIANT_BOOL pval  
true for visible, false to hide the window  

ICodeWarriorDocument.Visible Arguments:

Return Value

None


Saving a Document - Save

Saves a document.


Arguments

None


Return Value

None


Closing a Document - Close

Closes a document.


Arguments

None


Return Value

None


Getting the File Spec - FileSpec

Retrieves the document's IFileSpec.


Arguments

 

Argument
Functionality
IFileSpec** pval  
The file spec for the document  

ICodeWarriorDocument.FileSpec Arguments:

Return Value

None

ICodeWarriorDocument Example Usage:


Option Explicit
Dim theCodeWarriorApp
Dim theTextDocument
Dim theTextEngine
Dim theCollection
Main
Sub Main
	
	Dim theDocument
	Dim thePath
	Dim i
	
	'Create automation app object
	Set theCodeWarriorApp = CreateObject("CodeWarrior.CodeWarriorApp")
	
	'Get a TextEngine
	thePath = "C:\temp.txt"
	Set theTextDocument = theCodeWarriorApp.OpenTextDocument(thePath, true)
	Set theTextEngine = theTextDocument.TextEngine
	
	'Print a list of all the documents
	Set theCollection = theCodeWarriorApp.Documents
	For i = 0 to theCollection.Count - 1
		Set theDocument = theCollection.Item(i)
		theTextEngine.InsertText("Document: " + theDocument.Name + Chr(13))
	Next	
	
	'Print the active document
	Set theDocument = theCodeWarriorApp.ActiveDocument
	theTextEngine.InsertText(Chr(13) + "Active Document: " + theDocument.Name + Chr(13))
	
	'Print the FileSpecs
	PrintFileSpecs

	'Print readonly
	PrintReadOnly

	PrintModified

	MoveWindows

End Sub





' Prints fileSpecs
Sub PrintFileSpecs

	Dim theFileSpec
	Dim theDocument
	Dim i
	
	on error resume next

	theTextEngine.InsertText(Chr(13) + "FileSpecs: " + Chr(13))
	For i = 0 to theCollection.Count - 1
		Set theDocument = theCollection.Item(i)
		Set theFileSpec = theDocument.FileSpec
		theTextEngine.InsertText(theDocument.Name + " -> ")
		theTextEngine.InsertText(theFileSpec.FullPath + Chr(13))
	Next	
End Sub

' Prints names of readonly documents
Sub PrintReadOnly

	Dim theDocument
	Dim i
	
	'on error resume next

	theTextEngine.InsertText(Chr(13) + "ReadOnly Documents: " + Chr(13))
	For i = 0 to theCollection.Count - 1
		Set theDocument = theCollection.Item(i)
		if theDocument.ReadOnly then
			theTextEngine.InsertText(theDocument.Name + Chr(13))
		end if
	Next	
End Sub

' Prints names of modified documents
Sub PrintModified

	Dim theDocument
	Dim i
	
	'on error resume next

	theTextEngine.InsertText(Chr(13) + "Modified Documents: " + Chr(13))
	For i = 0 to theCollection.Count - 1
		Set theDocument = theCollection.Item(i)
		if theDocument.Dirty then
			theTextEngine.InsertText(theDocument.Name + Chr(13))
		end if
	Next	
End Sub

Sub MoveWindows
	Dim theDocument
	Dim x
	Dim y
	Dim width
	Dim height
	Dim z
	
	Set theDocument = theCodeWarriorApp.ActiveDocument
	x = theDocument.XPos
	y = theDocument.YPos
	width = theDocument.Width
	height = theDocument.Height
	theTextEngine.InsertText(x)
	theTextEngine.InsertText(Chr(13))
	theTextEngine.InsertText(y)
	theTextEngine.InsertText(Chr(13))
	theTextEngine.InsertText(width)
	theTextEngine.InsertText(Chr(13))
	theTextEngine.InsertText(height)
	theTextEngine.InsertText(Chr(13))

	x = 0
	y = 0
	width = 5
	height = 5
	theDocument.XPos = x
	theDocument.YPos = y
	theDocument.Width = width
	theDocument.Height = height

	theTextEngine.InsertText(x)
	theTextEngine.InsertText(Chr(13))
	theTextEngine.InsertText(y)
	theTextEngine.InsertText(Chr(13))
	theTextEngine.InsertText(width)
	theTextEngine.InsertText(Chr(13))
	theTextEngine.InsertText(height)
	
End Sub


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 02, 2000