aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard/UI/macOS/View/LogViewCell.swift
blob: 1e2312a1ce4f9daa2b1cc36e20ef61a3ffd6befb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-License-Identifier: MIT
// Copyright © 2018-2019 WireGuard LLC. All Rights Reserved.

import Cocoa

class LogViewCell: NSTextField {
    init() {
        super.init(frame: .zero)
        isSelectable = false
        isEditable = false
        isBordered = false
        backgroundColor = .clear
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func prepareForReuse() {
        stringValue = ""
        preferredMaxLayoutWidth = 0
    }
}

class LogViewTimestampCell: LogViewCell {
    override init() {
        super.init()
        maximumNumberOfLines = 1
        lineBreakMode = .byClipping
        preferredMaxLayoutWidth = 0
        setContentCompressionResistancePriority(.defaultHigh, for: .vertical)
        setContentHuggingPriority(.defaultLow, for: .vertical)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

class LogViewMessageCell: LogViewCell {
    override init() {
        super.init()
        maximumNumberOfLines = 0
        lineBreakMode = .byWordWrapping
        setContentCompressionResistancePriority(.required, for: .vertical)
        setContentHuggingPriority(.required, for: .vertical)
    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}