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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_FOCUSABLE_GRID_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_FOCUSABLE_GRID_H 18 19 #include <map> 20 21 #include "base/memory/ace_type.h" 22 #include "core/components/common/layout/constants.h" 23 24 namespace OHOS::Ace { 25 26 class FocusableGrid : public virtual AceType { 27 DECLARE_ACE_TYPE(FocusableGrid, AceType); 28 29 public: 30 int32_t RequestNextFocus(bool vertical, bool reverse); 31 32 protected: 33 virtual int32_t GetIndexByGrid(int32_t row, int32_t column) = 0; FocusChanged(int32_t oldIndex,int32_t newIndex)34 virtual void FocusChanged(int32_t oldIndex, int32_t newIndex) {} 35 36 int32_t focusRow_ = -1; 37 int32_t focusCol_ = -1; 38 int32_t colCount_ = 0; 39 int32_t rowCount_ = 0; 40 int32_t focusIndex_ = 0; 41 int32_t firstDayIndex_ = 0; 42 int32_t selectedDayNumber_ = 1; 43 44 private: 45 // Handle direction key move 46 int32_t FocusMove(KeyDirection direction); 47 }; 48 49 } // namespace OHOS::Ace 50 51 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_CALENDAR_FOCUSABLE_GRID_H 52