Unless otherwise specified, the following examples are based on bada SDK 1.0.0.
1. Image Loading Function
- Osp::Graphics::Bitmap*
-
- BaseForm::GetBitmapN(const Osp::Base::String& name)
-
- {
-
- Bitmap* pBitmap = null;
-
- Image* pImage = new Image();
-
- String fullname(L"/Res/");
-
- fullname.Append(name);
-
- pImage->Construct();
-
- if(fullname.EndsWith(L"jpg"))
-
- {
-
- pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565);
-
- }
-
- else if(fullname.EndsWith(L"bmp"))
-
- {
-
- pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565);
-
- }
-
- else if(fullname.EndsWith(L"png"))
-
- {
-
- pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_ARGB8888);
-
- }
-
- else if (fullname.EndsWith(L"gif"))
-
- {
-
- pBitmap = pImage->DecodeN(fullname, BITMAP_PIXEL_FORMAT_RGB565);
-
- }
-
- delete pImage;
-
- return pBitmap;
-
- }
2. Button
I have set the background image of the button. The example is as follows:
- Osp::Graphics::Bitmap *__pReturn;
-
- Osp::Graphics::Bitmap *__pReturnAct;
-
-
- static const int ID_BUTTON_RETURN = 100;
-
- __pReturn = GetBitmapN(L"return.png");
-
- __pReturnAct = GetBitmapN(L"returnact.png");
-
- Button *pBtnReturn = new Button();
-
- pBtnReturn->Construct(Rectangle(x, y, w, h), "");
-
- pBtnReturn->SetActionId(ID_BUTTON_RETURN);
-
- pBtnReturn->SetNormalBackgroundBitmap(*__pReturn);
-
- pBtnReturn->SetPressedBackgroundBitmap(*__pReturnAct);
-
- pBtnReturn->AddActionEventListener(*this);
-
- AddControl(*pBtnReturn);
-
- delete __pReturn;
-
- delete __pReturnAct;
3. EditField
- Osp: Ui: Controls: EditField * _ pAddrEdit;
-
- _ PAddrEdit = new EditField ();
-
- // The second parameter can be selected based on the text, and the maximum length of the text can be customized.
-
- _ PAddrEdit-> Construct (Rectangle (x, y, w, h), EDIT_FIELD_STYLE_URL_SMALL, INPUT_STYLE_FULLSCREEN, false, 300 );
-
- AddControl (* _ pAddrEdit );
-
- _ PAddrEdit-> SetEnabled (true );
-
- _ PAddrEdit-> SetKeypadEnabled (true );
-
- _ PAddrEdit-> SetText (L "http ://");
4. CheckButton
- CheckButton *pCheckBtn = new CheckButton();
-
- pCheckBtn->Construct(Rectangle(x, y, dx, dy),CHECK_BUTTON_STYLE_MARK, BACKGROUND_STYLE_NONE, false, "");
-
- pCheckBtn->SetActionId(ID_CHECK_BTN_ON, ID_CHECK_BTN_OFF);
-
- pCheckBtn->SetTextHorizontalAlignment(ALIGNMENT_LEFT); pCheck3G->AddActionEventListener(*this); AddControl(*pCheckBtn);
5. RadioGroup
- CheckButton *pCheckWap = new CheckButton();
-
- pCheckWap->Construct(Rectangle(x, y, w, h), CHECK_BUTTON_STYLE_RADIO, BACKGROUND_STYLE_NONE, false, L"wap");
-
- pCheckWap->SetActionId(ID_BUTTON_RADIOWAP_ON, ID_BUTTON_RADIOWAP_OFF);
-
- pCheckWap->AddActionEventListener(*this);
-
- AddControl(*pCheckWap);
-
- CheckButton *pCheckNet = new CheckButton();
-
- pCheckNet->Construct(Rectangle(x, y, w, h),CHECK_BUTTON_STYLE_RADIO, BACKGROUND_STYLE_NONE, false, L"net");
-
- pCheckNet->SetActionId(ID_BUTTON_RADIONET_ON, ID_BUTTON_RADIONET_OFF);
-
- pCheckNet->AddActionEventListener(*this);
-
- AddControl(*pCheckNet);
-
- RadioGroup *pRadioGroup = new RadioGroup();
-
- pRadioGroup->Construct();
-
- pRadioGroup->Add(*pCheckWap);
-
- pRadioGroup->Add(*pCheckNet);
-
- pRadioGroup->SetSelectedItem(*pCheckNet);
-
- AddControl(*pRadioGroup);