1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_VIEW_ABSTRACT_H
17 #define FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_VIEW_ABSTRACT_H
18 
19 #include <functional>
20 #include <optional>
21 #include <string>
22 #include <vector>
23 
24 #include "base/geometry/dimension.h"
25 #include "base/geometry/dimension_rect.h"
26 #include "base/json/json_util.h"
27 #include "base/log/ace_scoring_log.h"
28 #include "base/log/ace_trace.h"
29 #include "base/log/log.h"
30 #include "base/memory/ace_type.h"
31 #include "base/utils/macros.h"
32 #include "bridge/cj_frontend/interfaces/cj_ffi/cj_macro.h"
33 #include "core/common/container.h"
34 #include "core/components/common/properties/decoration.h"
35 #include "core/components/common/properties/placement.h"
36 #ifndef __OHOS_NG__
37 #include "core/components/box/box_component.h"
38 #include "core/components/display/display_component.h"
39 #include "core/components/menu/menu_component.h"
40 #include "core/components/theme/theme_manager.h"
41 #include "core/components/transform/transform_component.h"
42 #endif
43 #include "core/gestures/tap_gesture.h"
44 #include "core/pipeline/base/component.h"
45 #include "ffi_remote_data.h"
46 
47 namespace OHOS::Ace::Framework {
48 
49 enum class Align {
50     TOP_LEFT,
51     TOP_CENTER,
52     TOP_RIGHT,
53     CENTER_LEFT,
54     CENTER,
55     CENTER_RIGHT,
56     BOTTOM_LEFT,
57     BOTTOM_CENTER,
58     BOTTOM_RIGHT,
59 };
60 
61 enum class CJResponseType : int32_t {
62     RIGHT_CLICK = 0,
63     LONGPRESS,
64 };
65 
66 class ACE_EXPORT ViewAbstract : public OHOS::FFI::FFIData {
DECL_TYPE(ViewAbstract,OHOS::FFI::FFIData)67 DECL_TYPE(ViewAbstract, OHOS::FFI::FFIData)
68 public:
69     ViewAbstract() : FFIData() {}
70 
71     template<typename T>
GetTheme()72     static RefPtr<T> GetTheme()
73     {
74         auto currentObj = Container::Current();
75         if (!currentObj) {
76             LOGW("container is null");
77             return nullptr;
78         }
79         auto pipelineContext = currentObj->GetPipelineContext();
80         if (!pipelineContext) {
81             LOGE("pipelineContext is null!");
82             return nullptr;
83         }
84         auto themeManager = pipelineContext->GetThemeManager();
85         if (!themeManager) {
86             LOGE("themeManager is null!");
87             return nullptr;
88         }
89         return themeManager->GetTheme<T>();
90     }
91 
92     static RefPtr<ThemeConstants> GetThemeConstants();
93     static void CjEnabled(bool enabled);
94 
95 };
96 } // namespace OHOS::Ace::Framework
97 #endif // FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_VIEW_ABSTRACT_H
98