Mercurial > cgi-bin > hgweb.cgi > JpegWasher
annotate src/name/blackcap/exifwasher/HelpDialog.kt @ 59:4997ae108653
Add where Osdep is.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sun, 26 Jul 2020 14:26:06 -0700 |
parents | 94cd2d486adc |
children |
rev | line source |
---|---|
50
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
1 /* |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
2 * The dialog that displays the Exif data in a single file (display only, |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
3 * no changing). We do this after washing. |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
4 */ |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
5 package name.blackcap.exifwasher |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
6 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
7 import java.awt.Dimension |
53 | 8 import java.awt.Font |
50
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
9 import java.awt.event.ActionEvent |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
10 import java.awt.event.ActionListener |
53 | 11 import java.io.BufferedReader |
50
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
12 import java.io.File |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
13 import java.io.IOException |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
14 import java.io.InputStream |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
15 import java.io.InputStreamReader |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
16 import java.util.logging.Level |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
17 import java.util.logging.Logger |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
18 import javax.swing.* |
53 | 19 import javax.swing.text.html.HTMLEditorKit |
20 import javax.swing.text.html.StyleSheet | |
50
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
21 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
22 import name.blackcap.exifwasher.exiv2.* |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
23 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
24 class HelpDialog : JDialog(Application.mainFrame) { |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
25 private val BW = 9 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
26 private val BW2 = BW * 2 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
27 private val WIDTH = 640 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
28 private val HEIGHT = 480 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
29 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
30 private val dismissButton = JButton("Dismiss").also { |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
31 it.addActionListener(ActionListener { setVisible(false) }) |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
32 } |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
33 |
53 | 34 /* |
35 * The stock HTMLEditorKit shares all style sheet data between all its | |
36 * instances. How unbelievably braindamaged. Correct that. | |
37 */ | |
38 private class MyEditorKit: HTMLEditorKit() { | |
39 private var _styleSheet: StyleSheet = defaultStyleSheet | |
40 override fun getStyleSheet() = _styleSheet | |
41 override fun setStyleSheet(value: StyleSheet) { | |
42 _styleSheet = value | |
43 } | |
44 | |
45 /** | |
46 * Return the default style sheet that all HTMLEditorKit's come with. | |
47 */ | |
48 val defaultStyleSheet: StyleSheet | |
49 get() { | |
50 return super.getStyleSheet() | |
51 } | |
52 } | |
53 | |
52 | 54 private val helpPane = JScrollPane(JTextPane().also { |
57 | 55 it.editorKit = MyEditorKit().also { ek -> |
56 UIManager.getFont("Panel.font")?.let { pFont -> | |
53 | 57 ek.styleSheet = StyleSheet().apply { |
58 addRule("body { font-family: \"${pFont.family}\"; font-size: ${pFont.size}; }") | |
59 addStyleSheet(ek.defaultStyleSheet) | |
60 } | |
61 } | |
62 } | |
52 | 63 it.text = this::class.java.getResourceAsStream("help.html").bufferedReader().use { it.readText() } |
53 | 64 it.setEditable(false) |
52 | 65 }).apply { |
66 alignmentX = JScrollPane.CENTER_ALIGNMENT | |
54 | 67 addBorder(BorderFactory.createEmptyBorder(BW2, BW2, BW, BW2)) |
52 | 68 verticalScrollBarPolicy = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS |
69 horizontalScrollBarPolicy = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER | |
70 preferredSize = Dimension(WIDTH, HEIGHT) | |
71 background = Application.mainFrame.background | |
72 } | |
73 | |
74 override fun setVisible(vis: Boolean) { | |
75 if (vis) | |
76 helpPane.verticalScrollBar.run { value = minimum } | |
77 super.setVisible(vis) | |
50
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
78 } |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
79 |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
80 init { |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
81 setVisible(false) |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
82 title = "Help" |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
83 contentPane.apply { |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
84 layout = BoxLayout(this, BoxLayout.Y_AXIS) |
52 | 85 add(helpPane) |
50
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
86 add(Box(BoxLayout.X_AXIS).apply { |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
87 alignmentX = Box.CENTER_ALIGNMENT |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
88 border = BorderFactory.createEmptyBorder(BW, BW2, BW2, BW2) |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
89 add(Box.createHorizontalGlue()) |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
90 add(dismissButton) |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
91 }) |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
92 } |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
93 pack() |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
94 } |
fb407182ba76
Add help menu item, UNTESTED.
David Barts <davidb@stashtea.com>
parents:
diff
changeset
|
95 } |