1 /*
2  *	Copyright (C) 2004-2005 Vadim Berezniker
3  *	http://www.kryptolus.com
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with GNU Make; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21 
22 #include "stdafx.h"
23 
24 #include "common.h"
25 
kryStyle()26 kryStyle::kryStyle() :
27         m_prefix(NULL), m_font_anglex(0), m_font_angley(0), m_font_anglez(0),
28         m_font_size(18), m_font_scaley(100), m_font_scalex(100),
29         m_font_spacing(0),
30         m_color_primary(0x00FFFFFF), m_color_secondary(0x0000FFFF),
31         m_color_tertiary(0x0000FFFF), m_color_outline(0x00000000),
32         m_color_shadow(0x00000000), m_color_back(0x00000000),
33         m_bold(0), m_italic(0), m_border_style((enum border_style) 0),
34         m_shadow_size(3),  m_border_size(2), m_alignment(2),
35         m_margin_left(20), m_margin_right(20), m_margin_top(20), m_margin_bottom(20),
36         m_alpha_level(0),  m_charset(0), m_strikethrough(0),
37         m_underline(0), m_blur(0), m_relative(0), m_type(KRY_STYLE_SSA),
38         m_refcount(1)
39 {
40   m_name = kry_strdup("Default");
41   m_font_name = kry_strdup("Arial");
42 }
43 
~kryStyle()44 kryStyle::~kryStyle()
45 {
46   kry_free(this->m_font_name);
47   kry_free(this->m_name);
48 
49   if(this->m_prefix)
50     kry_free(this->m_prefix);
51 }
52 
Copy()53 kryStyle *kryStyle::Copy()
54 {
55   kryStyle *newStyle = new kryStyle();
56 
57   kry_free(newStyle->m_font_name);
58   kry_free(newStyle->m_name);
59 
60   *newStyle = *this;
61 
62   newStyle->m_font_name = kry_strdup(this->m_font_name);
63   newStyle->m_name = kry_strdup(this->m_name);
64 
65   if(this->m_prefix)
66     newStyle->m_prefix = kry_strdup(this->m_prefix);
67 
68   newStyle->m_refcount = 1;
69 
70   return newStyle;
71 }
72 
Compare(kryStyle * s2)73 gboolean kryStyle::Compare(kryStyle *s2)
74 {
75   return this->m_alignment == s2->m_alignment
76     && this->m_alpha_level == s2->m_alpha_level
77     && this->m_blur == s2->m_blur
78     && this->m_border_size == s2->m_border_size
79     && this->m_border_style == s2->m_border_style
80     && this->m_charset == s2->m_charset
81     && this->m_color_outline == s2->m_color_outline
82     && this->m_color_primary == s2->m_color_primary
83     && this->m_color_secondary == s2->m_color_secondary
84     && this->m_color_shadow == s2->m_color_shadow
85     && this->m_font_anglex == s2->m_font_anglex
86     && this->m_font_angley == s2->m_font_angley
87     && this->m_font_anglez == s2->m_font_anglez
88     && !strcmp(this->m_font_name, s2->m_font_name)
89     && this->m_font_scalex == s2->m_font_scalex
90     && this->m_font_scaley == s2->m_font_scaley
91     && this->m_font_size == s2->m_font_size
92     && this->m_font_spacing == s2->m_font_spacing
93     && this->m_italic == s2->m_italic
94     && this->m_margin_bottom == s2->m_margin_bottom
95     && this->m_margin_left == s2->m_margin_left
96     && this->m_margin_right == s2->m_margin_right
97     && this->m_margin_top == s2->m_margin_top
98     && this->m_relative == s2->m_relative
99     && this->m_shadow_size == s2->m_shadow_size
100     && this->m_strikethrough == s2->m_strikethrough
101     && this->m_underline == s2->m_underline
102     && this->m_bold == s2->m_bold;
103 }
104 
105 
GetFontSize()106 double kryStyle::GetFontSize()
107 {
108   return this->m_font_size;
109 }
110 
GetFontSizeStatic(kryStyle * style)111 double kryStyle::GetFontSizeStatic(kryStyle *style)
112 {
113   return style->GetFontSize();
114 }
115 
GetCharset()116 int kryStyle::GetCharset()
117 {
118   return this->m_charset;
119 }
120 
GetCharsetStatic(kryStyle * style)121 int kryStyle::GetCharsetStatic(kryStyle *style)
122 {
123   return style->GetCharset();
124 }
125 
SetStrikethrough(gboolean val)126 void kryStyle::SetStrikethrough(gboolean val)
127 {
128 	this->m_strikethrough = val;
129 }
130 
SetStrikethroughStatic(kryStyle * style,gboolean val)131 void kryStyle::SetStrikethroughStatic(kryStyle *style, gboolean val)
132 {
133   style->SetStrikethrough(val);
134 }
135 
SetUnderline(gboolean val)136 void kryStyle::SetUnderline(gboolean val)
137 {
138 	this->m_underline = val;
139 }
140 
SetUnderlineStatic(kryStyle * style,gboolean underline)141 void kryStyle::SetUnderlineStatic(kryStyle *style, gboolean underline)
142 {
143   style->SetUnderline(underline);
144 }
145 
SetItalic(gboolean val)146 void kryStyle::SetItalic(gboolean val)
147 {
148 	this->m_italic = val;
149 }
150 
SetItalicStatic(kryStyle * style,gboolean italic)151 void kryStyle::SetItalicStatic(kryStyle *style, gboolean italic)
152 {
153   style->SetItalic(italic);
154 }
155 
SetBold(gboolean val)156 void kryStyle::SetBold(gboolean val)
157 {
158 	this->m_bold = val;
159 }
160 
SetBoldStatic(kryStyle * style,gboolean bold)161 void kryStyle::SetBoldStatic(kryStyle *style, gboolean bold)
162 {
163   style->SetBold(bold);
164 }
165 
SetFontName(char * name)166 void kryStyle::SetFontName(char *name)
167 {
168 	if(this->m_font_name)
169 	{
170 		kry_free(this->m_font_name);
171 		this->m_font_name = NULL;
172 	}
173 
174 	if(!name)
175 		return;
176 
177 	this->m_font_name = kry_strdup(name);
178 }
179 
SetFontNameStatic(kryStyle * style,char * fontname)180 void kryStyle::SetFontNameStatic(kryStyle *style, char *fontname)
181 {
182   style->SetFontName(fontname);
183 }
184 
SetFontSize(double size)185 void kryStyle::SetFontSize(double size)
186 {
187 	this->m_font_size = size;
188 }
189 
SetFontSizeStatic(kryStyle * style,double size)190 void kryStyle::SetFontSizeStatic(kryStyle *style, double size)
191 {
192   style->SetFontSize(size);
193 }
194 
GetStrikethrough()195 gboolean kryStyle::GetStrikethrough()
196 {
197 	return this->m_strikethrough;
198 }
199 
GetStrikethroughStatic(kryStyle * style)200 gboolean kryStyle::GetStrikethroughStatic(kryStyle *style)
201 {
202   return style->GetStrikethrough();
203 }
204 
GetUnderline()205 gboolean kryStyle::GetUnderline()
206 {
207 	return this->m_underline;
208 }
209 
GetUnderlineStatic(kryStyle * style)210 gboolean kryStyle::GetUnderlineStatic(kryStyle *style)
211 {
212   return style->GetUnderline();
213 }
214 
GetItalic()215 gboolean kryStyle::GetItalic()
216 {
217 	return this->m_italic;
218 }
219 
GetItalicStatic(kryStyle * style)220 gboolean kryStyle::GetItalicStatic(kryStyle *style)
221 {
222   return style->GetItalic();
223 }
224 
GetBold()225 gboolean kryStyle::GetBold()
226 {
227 	return this->m_bold;
228 }
229 
GetBoldStatic(kryStyle * style)230 gboolean kryStyle::GetBoldStatic(kryStyle *style)
231 {
232   return style->GetBold();
233 }
234 
GetFontName()235 char *kryStyle::GetFontName()
236 {
237 	return this->m_font_name;
238 }
239 
GetFontNameStatic(kryStyle * style)240 char *kryStyle::GetFontNameStatic(kryStyle *style)
241 {
242   return style->GetFontName();
243 }
244 
SetAlignment(int alignment)245 void kryStyle::SetAlignment(int alignment)
246 {
247 	this->m_alignment = alignment;
248 }
249 
SetAlignmentStatic(kryStyle * style,int alignment)250 void kryStyle::SetAlignmentStatic(kryStyle *style, int alignment)
251 {
252   style->SetAlignment(alignment);
253 }
254 
GetAlignment()255 int kryStyle::GetAlignment()
256 {
257 	return this->m_alignment;
258 }
259 
GetAlignmentStatic(kryStyle * style)260 int kryStyle::GetAlignmentStatic(kryStyle *style)
261 {
262   return style->GetAlignment();
263 }
264 
GetAlphaLevel()265 int kryStyle::GetAlphaLevel()
266 {
267   return this->m_alpha_level;
268 }
269 
GetAlphaLevelStatic(kryStyle * style)270 int kryStyle::GetAlphaLevelStatic(kryStyle *style)
271 {
272   return style->GetAlphaLevel();
273 }
274 
SetAlphaLevel(int alpha)275 void kryStyle::SetAlphaLevel(int alpha)
276 {
277   this->m_alpha_level = alpha;
278 }
279 
SetAlphaLevelStatic(kryStyle * style,int level)280 void kryStyle::SetAlphaLevelStatic(kryStyle *style, int level)
281 {
282   style->SetAlphaLevel(level);
283 }
284 
GetType()285 enum style_type kryStyle::GetType()
286 {
287   return this->m_type;
288 }
289 
SetType(enum style_type type)290 void kryStyle::SetType(enum style_type type)
291 {
292   this->m_type = type;
293 }
294 
SetName(char * name)295 void kryStyle::SetName(char *name)
296 {
297 	if(this->m_name)
298 	{
299 		kry_free(this->m_name);
300 		this->m_name = NULL;
301 	}
302 
303 	if(!name)
304 		return;
305 
306 	this->m_name = kry_strdup(name);
307 }
308 
SetNameStatic(kryStyle * style,char * name)309 void kryStyle::SetNameStatic(kryStyle *style, char *name)
310 {
311   style->SetName(name);
312 }
313 
GetName()314 char *kryStyle::GetName()
315 {
316 	return this->m_name;
317 }
318 
GetNameStatic(kryStyle * style)319 char *kryStyle::GetNameStatic(kryStyle *style)
320 {
321   return style->GetName();
322 }
323 
GetFontScaleX()324 double kryStyle::GetFontScaleX()
325 {
326 	return this->m_font_scalex;
327 }
328 
GetFontScaleXStatic(kryStyle * style)329 double kryStyle::GetFontScaleXStatic(kryStyle *style)
330 {
331   return style->GetFontScaleX();
332 }
333 
SetFontScaleX(double scale)334 void kryStyle::SetFontScaleX(double scale)
335 {
336 	this->m_font_scalex = scale;
337 }
338 
SetFontScaleXStatic(kryStyle * style,double scale)339 void kryStyle::SetFontScaleXStatic(kryStyle *style, double scale)
340 {
341   style->SetFontScaleX(scale);
342 }
343 
GetFontScaleY()344 double kryStyle::GetFontScaleY()
345 {
346 	return this->m_font_scaley;
347 }
348 
GetFontScaleYStatic(kryStyle * style)349 double kryStyle::GetFontScaleYStatic(kryStyle *style)
350 {
351   return style->GetFontScaleY();
352 }
353 
SetFontScaleY(double scale)354 void kryStyle::SetFontScaleY(double scale)
355 {
356 	this->m_font_scaley = scale;
357 }
358 
SetFontScaleYStatic(kryStyle * style,double scale)359 void kryStyle::SetFontScaleYStatic(kryStyle *style, double scale)
360 {
361   style->SetFontScaleY(scale);
362 }
363 
GetFontSpacing()364 double kryStyle::GetFontSpacing()
365 {
366 	return this->m_font_spacing;
367 }
368 
GetFontSpacingStatic(kryStyle * style)369 double kryStyle::GetFontSpacingStatic(kryStyle *style)
370 {
371   return style->GetFontSpacing();
372 }
373 
SetFontSpacing(double spacing)374 void kryStyle::SetFontSpacing(double spacing)
375 {
376 	this->m_font_spacing = spacing;
377 }
378 
SetFontSpacingStatic(kryStyle * style,double spacing)379 void kryStyle::SetFontSpacingStatic(kryStyle *style, double spacing)
380 {
381   style->SetFontSpacing(spacing);
382 }
383 
GetFontAngleX()384 double kryStyle::GetFontAngleX()
385 {
386   return this->m_font_anglex;
387 }
388 
GetFontAngleY()389 double kryStyle::GetFontAngleY()
390 {
391   return this->m_font_angley;
392 }
393 
GetFontAngleZ()394 double kryStyle::GetFontAngleZ()
395 {
396   return this->m_font_anglez;
397 }
398 
GetFontAngleZStatic(kryStyle * style)399 double kryStyle::GetFontAngleZStatic(kryStyle *style)
400 {
401   return style->GetFontAngleZ();
402 }
403 
SetFontAngleX(double angle)404 void kryStyle::SetFontAngleX(double angle)
405 {
406   this->m_font_anglex = angle;
407 }
408 
SetFontAngleY(double angle)409 void kryStyle::SetFontAngleY(double angle)
410 {
411   this->m_font_angley = angle;
412 }
413 
SetFontAngleZ(double angle)414 void kryStyle::SetFontAngleZ(double angle)
415 {
416   this->m_font_anglez = angle;
417 }
418 
SetFontAngleZStatic(kryStyle * style,double angle)419 void kryStyle::SetFontAngleZStatic(kryStyle *style, double angle)
420 {
421   style->SetFontAngleZ(angle);
422 }
423 
GetBorderSize()424 double kryStyle::GetBorderSize()
425 {
426 	return this->m_border_size;
427 }
428 
GetBorderSizeStatic(kryStyle * style)429 double kryStyle::GetBorderSizeStatic(kryStyle *style)
430 {
431   return style->GetBorderSize();
432 }
433 
SetBorderSize(double size)434 void kryStyle::SetBorderSize(double size)
435 {
436 	this->m_border_size = size;
437 }
438 
SetBorderSizeStatic(kryStyle * style,double size)439 void kryStyle::SetBorderSizeStatic(kryStyle *style, double size)
440 {
441   style->SetBorderSize(size);
442 }
443 
GetShadowSize()444 double kryStyle::GetShadowSize()
445 {
446 	return this->m_shadow_size;
447 }
448 
GetShadowSizeStatic(kryStyle * style)449 double kryStyle::GetShadowSizeStatic(kryStyle *style)
450 {
451   return style->GetShadowSize();
452 }
453 
SetShadowSize(double size)454 void kryStyle::SetShadowSize(double size)
455 {
456 	this->m_shadow_size = size;
457 }
458 
SetShadowSizeStatic(kryStyle * style,double size)459 void kryStyle::SetShadowSizeStatic(kryStyle *style, double size)
460 {
461   style->SetShadowSize(size);
462 }
463 
GetMarginLeft()464 int kryStyle::GetMarginLeft()
465 {
466 	return this->m_margin_left;
467 }
468 
GetMarginLeftStatic(kryStyle * style)469 int kryStyle::GetMarginLeftStatic(kryStyle *style)
470 {
471   return style->GetMarginLeft();
472 }
473 
SetMarginLeft(int margin)474 void kryStyle::SetMarginLeft(int margin)
475 {
476 	this->m_margin_left = margin;
477 }
478 
SetMarginLeftStatic(kryStyle * style,int margin)479 void kryStyle::SetMarginLeftStatic(kryStyle *style, int margin)
480 {
481   style->SetMarginLeft(margin);
482 }
483 
GetMarginRight()484 int kryStyle::GetMarginRight()
485 {
486 	return this->m_margin_right;
487 }
488 
GetMarginRightStatic(kryStyle * style)489 int kryStyle::GetMarginRightStatic(kryStyle *style)
490 {
491   return style->GetMarginRight();
492 }
493 
SetMarginRight(int margin)494 void kryStyle::SetMarginRight(int margin)
495 {
496 	this->m_margin_right = margin;
497 }
498 
SetMarginRightStatic(kryStyle * style,int margin)499 void kryStyle::SetMarginRightStatic(kryStyle *style, int margin)
500 {
501   style->SetMarginRight(margin);
502 }
503 
GetMarginTop()504 int kryStyle::GetMarginTop()
505 {
506 	return this->m_margin_top;
507 }
508 
GetMarginBottom()509 int kryStyle::GetMarginBottom()
510 {
511   return this->m_margin_top;
512 }
513 
GetMarginTopStatic(kryStyle * style)514 int kryStyle::GetMarginTopStatic(kryStyle *style)
515 {
516   return style->GetMarginTop();
517 }
518 
SetMarginTop(int margin)519 void kryStyle::SetMarginTop(int margin)
520 {
521 	this->m_margin_top = margin;
522 }
523 
SetMarginBottom(int margin)524 void kryStyle::SetMarginBottom(int margin)
525 {
526 	this->m_margin_bottom = margin;
527 }
528 
SetMarginVertical(int margin)529 void kryStyle::SetMarginVertical(int margin)
530 {
531 	this->m_margin_bottom = this->m_margin_top = margin;
532 }
533 
SetMarginVerticalStatic(kryStyle * style,int margin)534 void kryStyle::SetMarginVerticalStatic(kryStyle *style, int margin)
535 {
536   style->SetMarginVertical(margin);
537 }
538 
SetBorderStyle(enum border_style style)539 void kryStyle::SetBorderStyle(enum border_style style)
540 {
541 	this->m_border_style = style;
542 }
543 
SetBorderStyleStatic(kryStyle * style,enum border_style type)544 void kryStyle::SetBorderStyleStatic(kryStyle *style, enum border_style type)
545 {
546   style->SetBorderStyle(type);
547 }
548 
GetBorderStyle()549 enum border_style kryStyle::GetBorderStyle()
550 {
551 	return this->m_border_style;
552 }
553 
GetBorderStyleStatic(kryStyle * style)554 enum border_style kryStyle::GetBorderStyleStatic(kryStyle *style)
555 {
556   return style->GetBorderStyle();
557 }
558 
SetColorPrimary(unsigned int color)559 void kryStyle::SetColorPrimary(unsigned int color)
560 {
561 	this->m_color_primary = color;
562 }
563 
SetColorPrimaryStatic(kryStyle * style,unsigned int color)564 void kryStyle::SetColorPrimaryStatic(kryStyle *style, unsigned int color)
565 {
566   style->SetColorPrimary(color);
567 }
568 
SetColorSecondary(unsigned int color)569 void kryStyle::SetColorSecondary(unsigned int color)
570 {
571 	this->m_color_secondary = color;
572 }
573 
SetColorSecondaryStatic(kryStyle * style,unsigned int color)574 void kryStyle::SetColorSecondaryStatic(kryStyle *style, unsigned int color)
575 {
576   style->SetColorSecondary(color);
577 }
578 
SetColorTertiary(unsigned int color)579 void kryStyle::SetColorTertiary(unsigned int color)
580 {
581 	this->m_color_tertiary = color;
582 }
583 
SetColorTertiaryStatic(kryStyle * style,unsigned int color)584 void kryStyle::SetColorTertiaryStatic(kryStyle *style, unsigned int color)
585 {
586   style->SetColorTertiary(color);
587 }
588 
SetColorOutline(unsigned int color)589 void kryStyle::SetColorOutline(unsigned int color)
590 {
591 	this->m_color_outline = color;
592   this->m_color_back = color;
593 }
594 
SetColorOutlineStatic(kryStyle * style,unsigned int color)595 void kryStyle::SetColorOutlineStatic(kryStyle *style, unsigned int color)
596 {
597   style->SetColorOutline(color);
598 }
599 
SetColorShadowStatic(kryStyle * style,unsigned int color)600 void kryStyle::SetColorShadowStatic(kryStyle *style, unsigned int color)
601 {
602   style->SetColorShadow(color);
603 }
604 
SetColorShadow(unsigned int color)605 void kryStyle::SetColorShadow(unsigned int color)
606 {
607 	this->m_color_shadow = color;
608 }
609 
SetColorBack(unsigned int color)610 void kryStyle::SetColorBack(unsigned int color)
611 {
612   this->m_color_back = color;
613   this->SetColorShadow(color);
614   this->SetColorOutline(color);
615 }
616 
SetColorBackStatic(kryStyle * style,unsigned int color)617 void kryStyle::SetColorBackStatic(kryStyle *style, unsigned int color)
618 {
619   style->SetColorBack(color);
620 }
621 
GetColorPrimary()622 unsigned int kryStyle::GetColorPrimary()
623 {
624 	return this->m_color_primary;
625 }
626 
GetColorPrimaryStatic(kryStyle * style)627 unsigned int kryStyle::GetColorPrimaryStatic(kryStyle *style)
628 {
629   return style->GetColorPrimary();
630 }
631 
GetColorSecondary()632 unsigned int kryStyle::GetColorSecondary()
633 {
634 	return this->m_color_secondary;
635 }
636 
GetColorSecondaryStatic(kryStyle * style)637 unsigned int kryStyle::GetColorSecondaryStatic(kryStyle *style)
638 {
639   return style->GetColorSecondary();
640 }
641 
GetColorTertiary()642 unsigned int kryStyle::GetColorTertiary()
643 {
644   return this->m_color_tertiary;
645 }
646 
GetColorTertiaryStatic(kryStyle * style)647 unsigned int kryStyle::GetColorTertiaryStatic(kryStyle *style)
648 {
649   return style->GetColorTertiary();
650 }
651 
GetColorOutline()652 unsigned int kryStyle::GetColorOutline()
653 {
654 	return this->m_color_outline;
655 }
656 
GetColorOutlineStatic(kryStyle * style)657 unsigned int kryStyle::GetColorOutlineStatic(kryStyle *style)
658 {
659   return style->GetColorOutline();
660 }
661 
GetColorShadow()662 unsigned int kryStyle::GetColorShadow()
663 {
664 	return this->m_color_shadow;
665 }
666 
GetColorShadowStatic(kryStyle * style)667 unsigned int kryStyle::GetColorShadowStatic(kryStyle *style)
668 {
669   return style->GetColorShadow();
670 }
671 
GetColorBack()672 unsigned int kryStyle::GetColorBack()
673 {
674 	return this->m_color_back;
675 }
676 
GetColorBackStatic(kryStyle * style)677 unsigned int kryStyle::GetColorBackStatic(kryStyle *style)
678 {
679   return style->GetColorShadow();
680 }
681 
GetColorPrimaryPtr()682 unsigned int *kryStyle::GetColorPrimaryPtr()
683 {
684 	return &this->m_color_primary;
685 }
686 
GetColorSecondaryPtr()687 unsigned int *kryStyle::GetColorSecondaryPtr()
688 {
689 	return &this->m_color_secondary;
690 }
691 
GetColorOutlinePtr()692 unsigned int *kryStyle::GetColorOutlinePtr()
693 {
694 	return &this->m_color_outline;
695 }
696 
GetColorShadowPtr()697 unsigned int *kryStyle::GetColorShadowPtr()
698 {
699 	return &this->m_color_shadow;
700 }
701 
SetBlur(int blur)702 void kryStyle::SetBlur(int blur)
703 {
704   this->m_blur = blur;
705 }
706 
GetBlur()707 int kryStyle::GetBlur()
708 {
709   return this->m_blur;
710 }
711 
SetCharset(int charset)712 void kryStyle::SetCharset(int charset)
713 {
714   this->m_charset = charset;
715 }
716 
SetCharsetStatic(kryStyle * style,int charset)717 void kryStyle::SetCharsetStatic(kryStyle *style, int charset)
718 {
719   style->SetCharset(charset);
720 }
721 
GetRelative()722 int kryStyle::GetRelative()
723 {
724   return this->m_relative;
725 }
726 
727 
Ref()728 void kryStyle::Ref()
729 {
730   this->m_refcount++;
731 }
732 
Unref()733 void kryStyle::Unref()
734 {
735   this->m_refcount--;
736   if(this->m_refcount == 0)
737   {
738     KRY_UTP(this);
739     delete this;
740   }
741 }
742 
DestroyStatic(kryStyle * style)743 void kryStyle::DestroyStatic(kryStyle *style)
744 {
745   delete style;
746 }
747 
748 #ifdef _WINDOWS
LoadIntoLogfont(LOGFONTW * logfonta)749 void kryStyle::LoadIntoLogfont(LOGFONTW *logfonta)
750 {
751   HDC hDC = GetDC(NULL);
752 
753   logfonta->lfCharSet = this->GetCharset();
754   logfonta->lfItalic = this->GetItalic();
755   logfonta->lfStrikeOut = this->GetStrikethrough();
756   logfonta->lfUnderline = this->GetUnderline();
757   logfonta->lfWeight = this->GetBold() ? 700 : 400;
758 
759   gunichar2 *font_utf16 = g_utf8_to_utf16(this->GetFontName(), -1, NULL, NULL, NULL);
760   wcsncpy(logfonta->lfFaceName, font_utf16, LF_FACESIZE);
761   g_free(font_utf16);
762 
763   logfonta->lfHeight = -MulDiv((int)(this->GetFontSize()+0.5), GetDeviceCaps(hDC, LOGPIXELSY), 72);
764 
765   ReleaseDC(NULL, hDC);
766 }
767 #endif
768 
GetPrefix()769 char *kryStyle::GetPrefix()
770 {
771   return this->m_prefix;
772 }
773 
SetPrefix(char * text)774 void kryStyle::SetPrefix(char *text)
775 {
776   if(this->m_prefix)
777     kry_free(this->m_prefix);
778 
779   this->m_prefix = kry_strdup(text);
780 }
781 
782 
783