12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- /*
- * ui_form.h
- *
- * Created on: 2021年8月20日
- * Author: pengzc
- */
- #ifndef JNI_CORE_UI_FORM_H_
- #define JNI_CORE_UI_FORM_H_
- #include "field.h"
- #include "control/ZKListView.h"
- class UIForm : public ZKListView::IItemClickListener,
- public ZKListView::AbsListAdapter {
- public:
- virtual ~UIForm();
- void Add(Field& field) {
- fields.push_back((Field*)&field);
- }
- void BindView(ZKListView* list_view) {
- list_view->setItemClickListener(this);
- list_view->setListAdapter(this);
- list_view_ = list_view;
- }
- void BindIds(int icon_id, int title_id,
- int value_id, int arraw_id, int only_title_id,
- int switch_id) {
- ids[Field::ICON] = icon_id;
- ids[Field::TITLE] = title_id;
- ids[Field::VALUE] = value_id;
- ids[Field::ARRAW] = arraw_id;
- ids[Field::ONLY_TITLE] = only_title_id;
- ids[Field::SWITCH] = switch_id;
- }
- void BindId(int key, int id) {
- ids[key] = id;
- }
- void Clear() {
- for (auto& f : fields) {
- delete f;
- }
- fields.clear();
- ids.clear();
- }
- void Invalidate() {
- if (list_view_) {
- list_view_->refreshListView();
- }
- }
- protected:
- virtual int getListItemCount(const ZKListView *pListView) const;
- virtual void obtainListItemData(ZKListView *pListView,
- ZKListView::ZKListItem *pListItem, int index);
- virtual void onItemClick(ZKListView *pListView, int index, int itemID);
- private:
- friend class Field;
- std::vector<Field*> fields;
- std::map<int, int> ids;
- ZKListView* list_view_;
- };
- #endif /* JNI_CORE_UI_FORM_H_ */
|