黑莓.常用函數

一、  初始化篇:

1.1、int screen_create_context( screen_context_t *pctx, int flags );

#include <screen/screen.h>

Function:創建一個新的背景

pctx:context指針;

flags:創建類型,包括SCREEN_APPLICATION_CONTEXT、SCREEN_WINDOW_MANAGER_CONTEXT、SCREEN_INPUT_PROVIDER_CONTEXT、SCREEN_POWER_MANAGER_CONTEXT;

返回值:0(窗口創建成功)、-1(窗口創建失敗);

 

1.2、int bps_initialize(void)

#include <sys/platform.h>

#include "bps/event.h"

Function:初始化BPS

 

 

1.3、bbutil_init_egl()

#include< bbutil.h>Function:初始化egl

返回值:存在返回值,EXIT_SECCUSS表示失敗。

 

1.4、 screen_destroy_context(screen_cxt);

#include< bbutil.h>

Function:關閉背景;

返回值:暫時不知道存不存在;

 

1.5、int navigator_request_events(int flags)

#include <stdbool.h>

#include <sys/platform.h>

#include "bps/event.h"

Function:聲明本應用需要獲取“Navigator”事件。

flags: 零(任何事情都處理),非零

返回值:BPS_SUCCESS 表示成功; BPS_FAILURE 表示失敗。

 

1.6、int bps_get_event(bps_event_t **event, int timeout_ms)

#include <sys/platform.h>

#include "bps/event.h"

Function:獲取事件

event: even用來儲存事件

timeout_ms:獲取事件的方式,可爲零、負值、正值。負數則表示bps_get_event方法會一直等待到獲取到一個事件爲止。如果第二個參數是零則表示bps_get_event不會等待,有事件就獲取,沒有事件就繼續執行後面的代碼。如果第二個參數是一個正整數則表示等待指定的時間,期間獲取到事件就返回,沒有獲取到事件就在指定的時間結束後返回。

返回值:BPS_SUCCESS(成功)、, BPS_FAILURE(出錯) 、BPS_SUCCESS(成功但是事件爲空);

 

1.7、intlocale_request_events(int flags)

#include <sys/platform.h>

#include "bps/event.h"

Function:starts to deliver locale status change events to your applicationusing BPS

flag: Thetypes of events to deliver. A value of zero indicates that all events arerequested. The meaning of non-zero values is reserved for future use.

 

1.8、int bps_event_get_domain(bps_event_t *event)

#include <sys/platform.h>

#include <stdint.h>

Function:獲得事件event的domain

返回值:會event的domain

 

1.9、int navigator_rotation_lock(bool locked)

#include <stdbool.h>

#include <sys/platform.h>

#include "bps/event.h"

Function:鎖定屏幕;

1.10、int screen_request_events(screen_context_t context)

#include <screen/screen.h>

#include <sys/platform.h>

#include "bps/event.h"

context:The libscreen context to use for event retrieval.

Function:申明使用屏幕事件。

 

二、   創建使用對話框篇:

 2.1、int dialog_request_events(int flags)

#include <sys/platform.h>
#include <stdbool.h>
#include "bps/event.h"
Function:starts to deliver dialog events to your application using BPS

flagsThe types of events to deliver

 

2.2、int dialog_create_alert(dialog_instance_t *dialog)

#include <sys/platform.h>

#include <stdbool.h>

#include "bps/event.h"

Function:創建一個對話框。

dialog:對話框指針;

return : BPS_SUCCESS(成功), BPS_FAFILURE(失敗);

 

2.3、int dialog_set_alert_message_text(dialog_instance_t dialog, constchar *text)

#include <sys/platform.h>

#include <stdbool.h>

#include "bps/event.h"

Function:設置對話框的。。。。。

dialog:The dialog to update.

text :The message text to display

Return:BPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise

 

2.4、int dialog_set_size(dialog_instance_t dialog, dialog_size_t size)

#include <sys/platform.h>

#include <stdbool.h>

#include "bps/event.h"

Function:Set the size of a dialog.

dialog: 對話框名稱

size:大小。typedef enum {

     DIALOG_SIZE_SMALL = 0  

     DIALOG_SIZE_MEDIUM = 1  

     DIALOG_SIZE_LARGE = 2  

     DIALOG_SIZE_TALL = 3  

     DIALOG_SIZE_FULL = 4  

} dialog_size_t;

Return:BPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise.

 

2.5、int dialog_set_cancel_required(dialog_instance_t dialog, boolcancel_required)

#include <sys/platform.h>

#include <stdbool.h>

#include "bps/event.h"

Function:指定應用程序是否需要明確取消對話框。

dialog:The dialog to update.

cancel_required:If true the application must cancel thedialog explicitly, if false the application doesn't need to cancel the dialogexplicitly.

Return:BPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise.

 

2.6、int dialog_show(dialog_instance_t dialog)

#include <sys/platform.h>

#include <stdbool.h>

#include "bps/event.h"

Function:顯示出對話框。

dialog:顯現的對話框指針。

Return:BPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise

 

2.7、int dialog_set_alert_message_text(dialog_instance_t dialog, const char *text)
#include <sys/platform.h>
#include <stdbool.h>
#include "bps/event.h"
Function:Set the message text of an alert dialog;
dialog:對話框指針。
text: The message text to display.
ReturnBPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise.
 

2.8、int dialog_update(dialog_instance_t dialog)

#include <sys/platform.h>

#include <stdbool.h>

#include "bps/event.h"

FunctionUpdate a dialog, 刷新,顯現字符。

dialog:The dialog to update.

ReturnBPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise.

 

2.9、int dialog_destroy(dialog_instance_t dialog)

#include <sys/platform.h>

#include <stdbool.h>

#include"bps/event.h"

Function:Destroy a dialog.

dialog:對話框指針。

Return:BPS_SUCCESS upon success, BPS_FAILUREwith errno set otherwise.

 

三、  窗口創建使用篇():先建立一個context然後再這之上建立窗口;

窗口的類型:SCREEN_APPLICATION_WINDOW:創建時的座標相對於全屏幕而已;

                         SCREEN_CHILD_WINDOW(子窗口):創建時的座標對於父窗口而言,一般用來存放對話框(dialog),需要在窗口組添加。

                         SCREEN_EMBEDDED_WINDOW:Used to embed a window control within an object. Like the childwindow, the X and Y coordinates of the embedded window are all relative to thetop left corner of the application window. You must add an embedded window toan application's window group, otherwise the embedded window is invisible(此我無法正確用中文表達出來).

3.1、int screen_create_context( screen_context_t *pctx, int flags );

#include <screen/screen.h>

Function:創建一個新的背景

pctx:窗口指針;

flags:創建類型,包括SCREEN_APPLICATION_CONTEXT、SCREEN_WINDOW_MANAGER_CONTEXT、SCREEN_INPUT_PROVIDER_CONTEXT、SCREEN_POWER_MANAGER_CONTEXT;

返回值:0(窗口創建成功)、-1(窗口創建失敗);

 

3.2、int screen_create_window( screen_window_t * pwin,                screen_context_t ctx );

#include <screen/screen.h>

Funtction:在某個context創建一個window。

pwin:窗口指針

ctx :cxt所要城建窗口的context

Return:0(成功)、-1(失敗)。

3.3、pid_t getpid( void );

#include <process.h>

Function:Get the process ID

3.4、int screen_create_window_group( screen_win1dow_t win, const char *name )

#include <screen/screen.h>

Function:Create a window group that other windows can join.

win:需要放在這個window group 中的窗口

name:可以用3.3來獲取;

(設置窗口屬性):

3.5、#include <screen/screen.h>

int screen_set_window_property_cv(screen_window_t win, int pname, int len, const char * param );

int screen_set_window_property_iv(screen_window_t win, int pname, const int * param );

int screen_set_window_property_llv(screen_window_t win, int pname, const long long * param );

int screen_set_window_property_pv(screen_window_t win, int pname, void ** param );

Function:設置窗口的屬性。

3.6、int paymentservice_purchase_request

 

 

四、虛擬鍵盤及事件獲取使用篇():

4.1、int virtualkeyboard_request_events(int flags)

#include <stdbool.h>
#include <sys/platform.h>
#include "bps/event.h"
#include <bps/virtualkeyboard.h>

flags: Thetypes of events to deliver. A value of zero indicates that all events arerequested. The meaning of non-zero values is reserved for future use.

Function:申明開始virtualkeyboard事件。

ReturnBPS_SUCCESS upon success, BPS_FAILURE with errno set otherwise.

 

4.2、void virtualkeyboard_show()

#include <stdbool.h>
#include <bps/virtualkeyboard.h>
#include <sys/platform.h>
#include "bps/event.h"

Function:打開虛擬鍵盤。

 

4.3、void virtualkeyboard_hide()

#include <stdbool.h>
#include <sys/platform.h>
#include "bps/event.h”
Function:隱藏虛擬鍵盤。
4.4、int bps_get_event(bps_event_t **event, int timeout_ms)
#include <sys/platform.h>
#include "bps/event.h"
Function:接收事件。
event:事件指針。
timeout_ms:等待的時間(可以爲-1,代表知道下一個事件發生爲止)。
Return:BPS_SUCCESS(成功,時間超時也返回這,但是event是空指針), BPS_FAILURE (失敗)
4.5、int bps_event_get_domain(bps_event_t *event)
#include <sys/platform.h>
#include <stdint.h>
Function:gets the domain of a BPS event。(可以說獲取bps流).
event: The event to get the domain of.
Return: The domain of the event.
4.6、int screen_get_domain()
#include <screen/screen.h>
#include <sys/platform.h>
#include "bps/event.h"
Function: gets the unique domain ID for the screen.(可以說是獲取screen流)。(程序裏面可以用4.5和4.6來判斷是否是屏幕事件)
Return:The domain ID for the screen.
4.7、int navigator_get_domain()
#include <stdbool.h>
#include <sys/platform.h>
#include "bps/event.h"
Function:gets the unique domain ID for the navigator service.
Return: The domain ID for the navigator service.(程序裏面可以用4、7和4.7來判斷是否是navigator service事件)
4.8、unsigned int bps_event_get_code(bps_event_t *event)
#include <sys/platform.h>
#include <stdint.h>
event:The event to get the code of.
Function:識別具體的的事件。
Return:The code of the event.
4.9、screen_event_t screen_event_get_event(bps_event_t *event)
#include <screen/screen.h>
#include <sys/platform.h>
#include "bps/event.h"
Function:extracts the libscreen screen_event_t that is stored within a BPS event.(識別是什麼屏幕事件並且存儲在event中,只有是屏幕事件纔可以使用);
Return:The libscreen screen_event_t.
4.10、#include <winmgr/iow.h>
 
int screen_set_event_property_cv( screen_event_t ev, int pname, int len, const char * param);
int screen_set_event_property_iv( screen_event_t ev, int pname,const int * param);
int screen_set_event_property_llv( screen_event_t ev, int pname, const long long * param);
 int screen_set_event_property_pv( screen_event_t ev, int pname, void ** param);
參數:
 
ev:事件(4.9中所獲取到的event);
pname: The name of the property whose value must change.有以下幾種:
    Event type: SCREEN_EVENT_CLOSESCREEN_PROPERTY_WINDOW
 
    Event type: SCREEN_EVENT_CREATESCREEN_PROPERTY_WINDOW
    SCREEN_PROPERTY_GROUP
 
    Event type: SCREEN_EVENT_DISPLAYSCREEN_PROPERTY_DISPLAY
    SCREEN_PROPERTY_ATTACHED
    SCREEN_PROPERTY_MIRROR_MODE
    SCREEN_PROPERTY_MODE
    SCREEN_PROPERTY_PROTECTION_ENABLE
 
    Event type: SCREEN_EVENT_EFFECT_COMPLETESCREEN_PROPERTY_EFFECT
 
    Event type: SCREEN_EVENT_IDLESCREEN_PROPERTY_IDLE_STATE
 
    Event type: SCREEN_EVENT_INPUTSCREEN_PROPERTY_DEVICE_INDEX
    SCREEN_PROPERTY_INPUT_VALUE
 
    Event type: SCREEN_EVENT_JOGSCREEN_PROPERTY_DEVICE_INDEX
    SCREEN_PROPERTY_JOG_COUNT
 
    Event type: SCREEN_EVENT_KEYBOARDSCREEN_PROPERTY_DEVICE_INDEX
    SCREEN_PROPERTY_KEY_CAP
    SCREEN_PROPERTY_KEY_FLAGS
    SCREEN_PROPERTY_KEY_MODIFIERS
    SCREEN_PROPERTY_KEY_SCAN
    SCREEN_PROPERTY_KEY_SYM
 
       Event type: SCREEN_EVENT_MTOUCH_RELEASESCREEN_PROPERTY_TIMESTAMP
    SCREEN_PROPERTY_POSITION
    SCREEN_PROPERTY_SEQUENCE_ID
SCREEN_PROPERTY_SIZE
SCREEN_PROPERTY_SOURCE_POSITION
SCREEN_PROPERTY_SOURCE_SIZE
SCREEN_PROPERTY_TOUCH_ID
SCREEN_PROPERTY_TOUCH_ORIENTATION
SCREEN_PROPERTY_TOUCH_PRESSURE
SCREEN_PROPERTY_TIMESTAMP
SCREEN_PROPERTY_WINDOW
 
Event type: SCREEN_EVENT_POINTERSCREEN_PROPERTY_BUTTONS
SCREEN_PROPERTY_DEVICE_INDEX
SCREEN_PROPERTY_POSITION
SCREEN_PROPERTY_SOURCE_POSITION
SCREEN_PROPERTY_WINDOW
 
Event type: SCREEN_EVENT_POSTSCREEN_PROPERTY_WINDOW
 
Event type: SCREEN_EVENT_PROPERTYSCREEN_PROPERTY_NAME
SCREEN_PROPERTY_WINDOW
 
Event type: SCREEN_EVENT_USERSCREEN_PROPERTY_USER_DATA
功能:
screen_set_event_property_cv():Takes a char value of a given
length.screen_set_event_property_iv():Takes an integer
value.screen_set_event_property_llv():Takes a long long
value.screen_set_event_property_pv():Takes a pointer to an opaque handle type.
Return:Nothing
4.11、void virtualkeyboard_change_options(virtualkeyboard_layout_t layout, virtualkeyboard_enter_t enter)
#include <stdbool.h>
#include <sys/platform.h>
#include "bps/event.h"
Function:changes the virtual keyboard layout and Enter key options.
參數:
    Layout:#include <stdbool.h>
           #include <sys/platform.h>
           #include "bps/event.h"
           typedef enum {
                   VIRTUALKEYBOARD_LAYOUT_DEFAULT = 0   
                   VIRTUALKEYBOARD_LAYOUT_URL = 1   
                   VIRTUALKEYBOARD_LAYOUT_EMAIL = 2   
                   VIRTUALKEYBOARD_LAYOUT_WEB = 3   
                   VIRTUALKEYBOARD_LAYOUT_NUM_PUNC = 4   
                   VIRTUALKEYBOARD_LAYOUT_SYMBOL = 5   
                   VIRTUALKEYBOARD_LAYOUT_PHONE = 6   
                   VIRTUALKEYBOARD_LAYOUT_PIN = 7   
           } virtualkeyboard_layout_t;
       enter:
           #include <stdbool.h>
               #include <sys/platform.h>
               #include "bps/event.h"
               typedef enum {
                       VIRTUALKEYBOARD_ENTER_DEFAULT = 0   
                       VIRTUALKEYBOARD_ENTER_GO = 1   
                       VIRTUALKEYBOARD_ENTER_JOIN = 2   
                       VIRTUALKEYBOARD_ENTER_NEXT = 3   
                       VIRTUALKEYBOARD_ENTER_SEARCH = 4   
                       VIRTUALKEYBOARD_ENTER_SEND = 5   
                       VIRTUALKEYBOARD_ENTER_SUBMIT = 6   
                       VIRTUALKEYBOARD_ENTER_DONE = 7   
                       VIRTUALKEYBOARD_ENTER_CONNECT = 8   
           } virtualkeyboard_enter_t;
 
發佈了30 篇原創文章 · 獲贊 11 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章