• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #include "start_options.h"
17 
18 namespace OHOS {
19 namespace AAFwk {
StartOptions(const StartOptions & other)20 StartOptions::StartOptions(const StartOptions &other)
21 {
22     windowMode_ = other.windowMode_;
23     displayId_ = other.displayId_;
24     withAnimation_ = other.withAnimation_;
25     windowLeft_ = other.windowLeft_;
26     windowTop_ = other.windowTop_;
27     windowWidth_ = other.windowWidth_;
28     windowHeight_ = other.windowHeight_;
29     windowLeftUsed_ = other.windowLeftUsed_;
30     windowTopUsed_ = other.windowTopUsed_;
31     windowWidthUsed_ = other.windowWidthUsed_;
32     windowHeightUsed_ = other.windowHeightUsed_;
33 }
34 
operator =(const StartOptions & other)35 StartOptions &StartOptions::operator=(const StartOptions &other)
36 {
37     if (this != &other) {
38         windowMode_ = other.windowMode_;
39         displayId_ = other.displayId_;
40         withAnimation_ = other.withAnimation_;
41         windowLeft_ = other.windowLeft_;
42         windowTop_ = other.windowTop_;
43         windowWidth_ = other.windowWidth_;
44         windowHeight_ = other.windowHeight_;
45         windowLeftUsed_ = other.windowLeftUsed_;
46         windowTopUsed_ = other.windowTopUsed_;
47         windowWidthUsed_ = other.windowWidthUsed_;
48         windowHeightUsed_ = other.windowHeightUsed_;
49     }
50     return *this;
51 }
52 
ReadFromParcel(Parcel & parcel)53 bool StartOptions::ReadFromParcel(Parcel &parcel)
54 {
55     SetWindowMode(parcel.ReadInt32());
56     SetDisplayID(parcel.ReadInt32());
57     SetWithAnimation(parcel.ReadBool());
58     SetWindowLeft(parcel.ReadInt32());
59     SetWindowTop(parcel.ReadInt32());
60     SetWindowWidth(parcel.ReadInt32());
61     SetWindowHeight(parcel.ReadInt32());
62     windowLeftUsed_ = parcel.ReadBool();
63     windowTopUsed_ = parcel.ReadBool();
64     windowWidthUsed_ = parcel.ReadBool();
65     windowHeightUsed_ = parcel.ReadBool();
66     return true;
67 }
68 
Unmarshalling(Parcel & parcel)69 StartOptions *StartOptions::Unmarshalling(Parcel &parcel)
70 {
71     StartOptions *option = new (std::nothrow) StartOptions();
72     if (option == nullptr) {
73         return nullptr;
74     }
75 
76     if (!option->ReadFromParcel(parcel)) {
77         delete option;
78         option = nullptr;
79     }
80 
81     return option;
82 }
83 
Marshalling(Parcel & parcel) const84 bool StartOptions::Marshalling(Parcel &parcel) const
85 {
86     parcel.WriteInt32(GetWindowMode());
87     parcel.WriteInt32(GetDisplayID());
88     parcel.WriteBool(GetWithAnimation());
89     parcel.WriteInt32(GetWindowLeft());
90     parcel.WriteInt32(GetWindowTop());
91     parcel.WriteInt32(GetWindowWidth());
92     parcel.WriteInt32(GetWindowHeight());
93     parcel.WriteBool(windowLeftUsed_);
94     parcel.WriteBool(windowTopUsed_);
95     parcel.WriteBool(windowWidthUsed_);
96     parcel.WriteBool(windowHeightUsed_);
97     return true;
98 }
99 
SetWindowMode(int32_t windowMode)100 void StartOptions::SetWindowMode(int32_t windowMode)
101 {
102     windowMode_ = windowMode;
103 }
104 
GetWindowMode() const105 int32_t StartOptions::GetWindowMode() const
106 {
107     return windowMode_;
108 }
109 
SetDisplayID(int32_t id)110 void StartOptions::SetDisplayID(int32_t id)
111 {
112     displayId_ = id;
113 }
114 
GetDisplayID() const115 int32_t StartOptions::GetDisplayID() const
116 {
117     return displayId_;
118 }
119 
SetWithAnimation(bool withAnimation)120 void StartOptions::SetWithAnimation(bool withAnimation)
121 {
122     withAnimation_ = withAnimation;
123 }
124 
GetWithAnimation() const125 bool StartOptions::GetWithAnimation() const
126 {
127     return withAnimation_;
128 }
129 
SetWindowLeft(int32_t windowLeft)130 void StartOptions::SetWindowLeft(int32_t windowLeft)
131 {
132     windowLeft_ = windowLeft;
133 }
134 
GetWindowLeft() const135 int32_t StartOptions::GetWindowLeft() const
136 {
137     return windowLeft_;
138 }
139 
SetWindowTop(int32_t windowTop)140 void StartOptions::SetWindowTop(int32_t windowTop)
141 {
142     windowTop_ = windowTop;
143 }
144 
GetWindowTop() const145 int32_t StartOptions::GetWindowTop() const
146 {
147     return windowTop_;
148 }
149 
SetWindowWidth(int32_t windowWidth)150 void StartOptions::SetWindowWidth(int32_t windowWidth)
151 {
152     windowWidth_ = windowWidth;
153 }
154 
GetWindowWidth() const155 int32_t StartOptions::GetWindowWidth() const
156 {
157     return windowWidth_;
158 }
159 
SetWindowHeight(int32_t windowHeight)160 void StartOptions::SetWindowHeight(int32_t windowHeight)
161 {
162     windowHeight_ = windowHeight;
163 }
164 
GetWindowHeight() const165 int32_t StartOptions::GetWindowHeight() const
166 {
167     return windowHeight_;
168 }
169 }  // namespace AAFwk
170 }  // namespace OHOS
171