Platforms to show: All Mac Windows Linux Cross-Platform
/Cocoa/InstantMessage
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Cocoa/InstantMessage
This example is the version from Wed, 31th Mar 2009.
Notes: Last modified: Wed, 31th Mar 2009
Feedback.
Function:
You find this example project in your Plugins Download as a Realbasic project file within the examples folder: /Cocoa/InstantMessage
This example is the version from Wed, 31th Mar 2009.
Notes: Last modified: Wed, 31th Mar 2009
Class Window1
Inherits Window
// Controls
ControlInstance
End ControlInstance
ControlInstance
Sub Action() Handles Event
updatemystatus
End Sub
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
End ControlInstance
ControlInstance
Function CellBackgroundPaint(g As Graphics, row As Integer, column As Integer) As Boolean Handles Event
dim p as Picture
p=me.CellTag(row,0)
g.DrawPicture p,3,3
p=me.CellTag(row,1)
g.DrawPicture p,13,3
Return true
End Function
End ControlInstance
// Properties
Protected Dim InstantMessage As InstantMessageMBS
// Event implementations
Sub Open()
InstantMessage=new MyInstantMessageMBS
updatemystatus
End Sub
// Methods
Sub updatemystatus()
dim sa as IMServiceArrayMBS
dim s as IMServiceMBS
dim i,c,ii,cc as integer
dim si as IMServiceInfoMBS
dim sia as IMServiceInfoArrayMBS
Status.text=ServiceStatus(InstantMessage.myStatus)
IdleTime.text=str(InstantMessage.myIdleTime)+"s"
Canvas1.Backdrop=GetStatusPicture(InstantMessage.myStatus)
list.DeleteAllRows
List.ColumnAlignmentOffset(0)=80
sa=InstantMessage.allServices
if sa<>Nil then
c=sa.Count-1
for i=0 to c
s=sa.Item(i)
list.AddRow s.Name+" ("+s.LocalizedName+") - "+ServiceStatus(s.Status)
List.cellbold(list.LastIndex,0)=true
sia=s.infoForAllScreenNames
cc=sia.Count-1
for ii=0 to cc
si=sia.Item(ii)
List.AddRow si.ScreenName+": "+si.FirstName+" "+si.LastName+" - "+si.StatusMessage
dim data as string=si.PictureData
dim n as new NSImageMBS(data)
if n<>nil then
List.CellTag(list.LastIndex,1)=n.CopyPicture
end if
List.CellTag(list.LastIndex,0)=GetStatusPicture(si.Status)
next
next
end if
End Sub
Protected Function ServiceStatus(n as integer) As string
Select case n
case IMServiceMBS.IMServiceStatusDisconnected
return "Disconnected"
case IMServiceMBS.IMServiceStatusLoggedIn
return "LoggedIn"
case IMServiceMBS.IMServiceStatusLoggedOut
return "LoggedOut"
case IMServiceMBS.IMServiceStatusLoggingIn
return "LoggingIn"
case IMServiceMBS.IMServiceStatusLoggingOut
return "LoggingOut"
else
return "unknown?"
end Select
End Function
Protected Function GetStatusPicture(n as integer) As picture
dim name as string
dim image as NSImageMBS
name=InstantMessage.imageNameForStatus(n)
if name<>"" then
image=NSImageMBS.imageNamed(name)
if image<>nil then
Return image.CopyPictureWithMask
end if
end if
// old way:
dim file as FolderItem
dim t as TiffPictureMBS
file=InstantMessage.imageFileForStatus(n)
if file<>Nil then
t=file.OpenAsTiffMBS
if t<>nil then
Return t.CombinePictureWithMask
end if
end if
End Function
Sub Update()
// just to keep it not updating 100 times a second
timer1.mode=1
End Sub
End Class
Class App
Inherits Application
// Event implementations
Sub Open()
if TargetMachO=false then
MsgBox "This example needs a MachO target running on Mac OS X."
quit
end if
End Sub
End Class
Class MyInstantMessageMBS
Inherits InstantMessageMBS
// Event implementations
Sub PersonStatusChanged(info as IMServiceInfoMBS)
window1.Update
End Sub
Sub ServiceStatusChanged()
window1.Update
End Sub
Sub PersonInfoChanged(info as IMServiceInfoMBS)
window1.Update
End Sub
End Class
Links
MBS Realbasic Chart Plugins - Bilder aus Nickenich