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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
crate::ix!();
//-------------------------------------------[.cpp/bitcoin/src/qt/platformstyle.h]
/**
| Coin network-specific GUI style information
|
*/
pub struct PlatformStyle {
name: String,
images_on_buttons: bool,
colorize_icons: bool,
use_extra_spacing: bool,
}
impl PlatformStyle {
pub fn get_name(&self) -> &String {
todo!();
/*
return name;
*/
}
pub fn get_images_on_buttons(&self) -> bool {
todo!();
/*
return imagesOnButtons;
*/
}
pub fn get_use_extra_spacing(&self) -> bool {
todo!();
/*
return useExtraSpacing;
*/
}
pub fn new(
name: &String,
images_on_buttons: bool,
colorize_icons: bool,
use_extra_spacing: bool) -> Self {
todo!();
/*
:
name(_name),
imagesOnButtons(_imagesOnButtons),
colorizeIcons(_colorizeIcons),
useExtraSpacing(_useExtraSpacing)
*/
}
pub fn text_color(&self) -> QColor {
todo!();
/*
return QApplication::palette().color(QPalette::WindowText);
*/
}
pub fn single_color(&self) -> QColor {
todo!();
/*
if (colorizeIcons) {
const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight));
const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText));
const QColor colorText(QApplication::palette().color(QPalette::WindowText));
const int colorTextLightness = colorText.lightness();
if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) {
return colorHighlightBg;
}
return colorHighlightFg;
}
return {0, 0, 0};
*/
}
/**
| Colorize an image (given filename)
| with the icon color
|
*/
pub fn single_color_image(&self, filename: &String) -> QImage {
todo!();
/*
if (!colorizeIcons)
return QImage(filename);
return ColorizeImage(filename, SingleColor());
*/
}
/**
| Colorize an icon (given filename) with
| the icon color
|
*/
pub fn single_color_icon_with_filename(&self, filename: &String) -> QIcon {
todo!();
/*
if (!colorizeIcons)
return QIcon(filename);
return ColorizeIcon(filename, SingleColor());
*/
}
/**
| Colorize an icon (given object) with
| the icon color
|
*/
pub fn single_color_icon(&self, icon: &QIcon) -> QIcon {
todo!();
/*
if (!colorizeIcons)
return icon;
return ColorizeIcon(icon, SingleColor());
*/
}
/**
| Colorize an icon (given object) with
| the text color
|
*/
pub fn text_color_icon(&self, icon: &QIcon) -> QIcon {
todo!();
/*
return ColorizeIcon(icon, TextColor());
*/
}
/**
| Get style associated with provided
| platform name, or 0 if not known
|
*/
pub fn instantiate(&mut self, platform_id: &String) -> *const PlatformStyle {
todo!();
/*
for (const auto& platform_style : platform_styles) {
if (platformId == platform_style.platformId) {
return new PlatformStyle(
platform_style.platformId,
platform_style.imagesOnButtons,
platform_style.colorizeIcons,
platform_style.useExtraSpacing);
}
}
return nullptr;
*/
}
}
//-------------------------------------------[.cpp/bitcoin/src/qt/platformstyle.cpp]
pub struct PlatformStyleDescriptor {
platform_id: &'static str,
/**
| Show images on push buttons
|
*/
images_on_buttons: bool,
/**
| Colorize single-color icons
|
*/
colorize_icons: bool,
/**
| Extra padding/spacing in transactionview
|
*/
use_extra_spacing: bool,
}
pub const PLATFORM_STYLES: &[PlatformStyleDescriptor] = &[
PlatformStyleDescriptor {
platform_id: "macosx",
images_on_buttons: false,
colorize_icons: true,
use_extra_spacing: true,
},
PlatformStyleDescriptor {
platform_id: "windows",
images_on_buttons: true,
colorize_icons: false,
use_extra_spacing: false,
},
/**
| Other: linux, unix, ...
|
*/
PlatformStyleDescriptor {
platform_id: "other",
images_on_buttons: true,
colorize_icons: true,
use_extra_spacing: false,
}
];
/*
| Local functions for colorizing single-color
| images
|
*/
pub fn make_single_color_image(
img: &mut QImage,
colorbase: &QColor) {
todo!();
/*
img = img.convertToFormat(QImage::Format_ARGB32);
for (int x = img.width(); x--; )
{
for (int y = img.height(); y--; )
{
const QRgb rgb = img.pixel(x, y);
img.setPixel(x, y, qRgba(colorbase.red(), colorbase.green(), colorbase.blue(), qAlpha(rgb)));
}
}
*/
}
pub fn colorize_icon(
ico: &QIcon,
colorbase: &QColor) -> QIcon {
todo!();
/*
QIcon new_ico;
for (const QSize& sz : ico.availableSizes())
{
QImage img(ico.pixmap(sz).toImage());
MakeSingleColorImage(img, colorbase);
new_ico.addPixmap(QPixmap::fromImage(img));
}
return new_ico;
*/
}
pub fn colorize_image(
filename: &String,
colorbase: &QColor) -> QImage {
todo!();
/*
QImage img(filename);
MakeSingleColorImage(img, colorbase);
return img;
*/
}
pub fn colorize_icon_with_filename(
filename: &String,
colorbase: &QColor) -> QIcon {
todo!();
/*
return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase)));
*/
}