File: w_main.srw
Size: 7960
Date: Mon, 31 Dec 2018 21:14:39 +0100
$PBExportHeader$w_main.srw
forward
global type w_main from window
end type
type cb_timeline from commandbutton within w_main
end type
type st_3 from statictext within w_main
end type
type sle_message from singlelineedit within w_main
end type
type cb_clipboard from commandbutton within w_main
end type
type mle_response from multilineedit within w_main
end type
type st_2 from statictext within w_main
end type
type sle_status from singlelineedit within w_main
end type
type st_1 from statictext within w_main
end type
type cb_sendmsg from commandbutton within w_main
end type
type cb_cancel from commandbutton within w_main
end type
end forward

global type w_main from window
integer width = 2354
integer height = 1644
boolean titlebar = true
string title = "Twitter"
boolean controlmenu = true
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
cb_timeline cb_timeline
st_3 st_3
sle_message sle_message
cb_clipboard cb_clipboard
mle_response mle_response
st_2 st_2
sle_status sle_status
st_1 st_1
cb_sendmsg cb_sendmsg
cb_cancel cb_cancel
end type
global w_main w_main

type variables
n_twitter in_twit

end variables

on w_main.create
this.cb_timeline=create cb_timeline
this.st_3=create st_3
this.sle_message=create sle_message
this.cb_clipboard=create cb_clipboard
this.mle_response=create mle_response
this.st_2=create st_2
this.sle_status=create sle_status
this.st_1=create st_1
this.cb_sendmsg=create cb_sendmsg
this.cb_cancel=create cb_cancel
this.Control[]={this.cb_timeline,&
this.st_3,&
this.sle_message,&
this.cb_clipboard,&
this.mle_response,&
this.st_2,&
this.sle_status,&
this.st_1,&
this.cb_sendmsg,&
this.cb_cancel}
end on

on w_main.destroy
destroy(this.cb_timeline)
destroy(this.st_3)
destroy(this.sle_message)
destroy(this.cb_clipboard)
destroy(this.mle_response)
destroy(this.st_2)
destroy(this.sle_status)
destroy(this.st_1)
destroy(this.cb_sendmsg)
destroy(this.cb_cancel)
end on

type cb_timeline from commandbutton within w_main
integer x = 512
integer y = 1408
integer width = 370
integer height = 100
integer taborder = 50
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Timeline"
end type

event clicked;Boolean lb_result
String ls_ConsumerKey, ls_ConsumerSecret

SetPointer(HourGlass!)

// values from Twitter account sending the message
ls_ConsumerKey       = "???"
ls_ConsumerSecret    = "???"

// set the keys/tokens
in_twit.of_SetConsumerKeys(ls_ConsumerKey, ls_ConsumerSecret)

// send the tweet
lb_result = in_twit.of_User_Timeline("TopwizSoftware", 3)

// show the result
sle_status.text   = String(in_twit.httpstatus)
mle_response.text = in_twit.responseText

end event

type st_3 from statictext within w_main
integer x = 73
integer y = 76
integer width = 256
integer height = 60
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "Message:"
boolean focusrectangle = false
end type

type sle_message from singlelineedit within w_main
integer x = 512
integer y = 64
integer width = 1760
integer height = 84
integer taborder = 10
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

type cb_clipboard from commandbutton within w_main
integer x = 951
integer y = 1408
integer width = 370
integer height = 100
integer taborder = 60
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Clipboard"
end type

event clicked;Clipboard(mle_response.text)

end event

type mle_response from multilineedit within w_main
integer x = 512
integer y = 384
integer width = 1760
integer height = 924
integer taborder = 30
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
boolean vscrollbar = true
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type st_2 from statictext within w_main
integer x = 73
integer y = 404
integer width = 407
integer height = 60
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "ResponseText:"
boolean focusrectangle = false
end type

type sle_status from singlelineedit within w_main
integer x = 512
integer y = 224
integer width = 187
integer height = 84
integer taborder = 20
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
boolean displayonly = true
borderstyle borderstyle = stylelowered!
end type

type st_1 from statictext within w_main
integer x = 73
integer y = 236
integer width = 370
integer height = 60
integer textsize = -8
integer weight = 700
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "HTTP Status:"
boolean focusrectangle = false
end type

type cb_sendmsg from commandbutton within w_main
integer x = 73
integer y = 1408
integer width = 370
integer height = 100
integer taborder = 40
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Send Msg"
boolean default = true
end type

event clicked;Boolean lb_result
Long ll_ErrCode
String ls_ConsumerKey, ls_ConsumerSecret
String ls_AccessToken, ls_AccessTokenSecret
String ls_UserAgent, ls_StatusMsg
String ls_TweetId, ls_ErrText

SetPointer(HourGlass!)

ls_StatusMsg = sle_message.text
If ls_StatusMsg = "" Then
   MessageBox(this.text, "Message is required!", StopSign!)
   sle_message.SetFocus()
   Return
End If

// values from Twitter account sending the message
ls_ConsumerKey       = "???"
ls_ConsumerSecret    = "???"
ls_AccessToken       = "???"
ls_AccessTokenSecret = "???"

// set the keys/tokens
in_twit.of_SetConsumerKeys(ls_ConsumerKey, ls_ConsumerSecret)
in_twit.of_SetAccessTokens(ls_AccessToken, ls_AccessTokenSecret)

// send the tweet
lb_result = in_twit.of_Status_Update(ls_StatusMsg)

// show the result
sle_status.text   = String(in_twit.httpstatus)
mle_response.text = in_twit.responseText

If lb_result Then
   ls_TweetId = in_twit.of_GetJSONResponseString("id_str")
   MessageBox(this.text, &
      "Tweet #" + ls_TweetId + " sent:~r~n~r~n" + ls_StatusMsg)
Else
   ll_ErrCode = in_twit.of_GetJSONResponseNumber("code")
   ls_ErrText = in_twit.of_GetJSONResponseString("message")
   MessageBox(this.text, &
      "Error #" + String(ll_ErrCode) + " - " + ls_ErrText, StopSign!)
End If

end event

type cb_cancel from commandbutton within w_main
integer x = 1938
integer y = 1408
integer width = 334
integer height = 100
integer taborder = 70
integer textsize = -8
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Cancel"
boolean cancel = true
end type

event clicked;Close(Parent)

end event