博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Font: a C++ class
阅读量:5291 次
发布时间:2019-06-14

本文共 2769 字,大约阅读时间需要 9 分钟。

Font: a C++ class

        
This class is used in
    Fractal Generator.
    Avi Examples
The header file
Font.h
/*
   Font.h
   Copyright (C) 2002-2005 René Nyffenegger
   This source code is provided 'as-is', without any express or implied
   warranty. In no event will the author be held liable for any damages
   arising from the use of this software.
   Permission is granted to anyone to use this software for any purpose,
   including commercial applications, and to alter it and redistribute it
   freely, subject to the following restrictions:
   1. The origin of this source code must not be misrepresented; you must not
      claim that you wrote the original source code. If you use this source code
      in a product, an acknowledgment in the product documentation would be
      appreciated but is not required.
   2. Altered source versions must be plainly marked as such, and must not be
      misrepresented as being the original source code.
   3. This notice may not be removed or altered from any source distribution.
   René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
#ifndef FONT_H_
#define FONT_H_
#include <string>
#include <sstream>
#include <windows.h>
#include "STD_STR.h"
class Font {
  public:
  Font(STD_STR const& name, int size=12, bool bold=false, bool italic=false, bool underlined=false);
 ~Font();
  protected:
    friend class DC;
    Font(HFONT f) : font_(f){};
    operator HFONT() const {return font_;};
  private:
    HFONT font_;
};
#endif
The implementation file
Font.cpp
/*
   Font.cpp
   Copyright (C) 2002-2004 René Nyffenegger
   This source code is provided 'as-is', without any express or implied
   warranty. In no event will the author be held liable for any damages
   arising from the use of this software.
   Permission is granted to anyone to use this software for any purpose,
   including commercial applications, and to alter it and redistribute it
   freely, subject to the following restrictions:
   1. The origin of this source code must not be misrepresented; you must not
      claim that you wrote the original source code. If you use this source code
      in a product, an acknowledgment in the product documentation would be
      appreciated but is not required.
   2. Altered source versions must be plainly marked as such, and must not be
      misrepresented as being the original source code.
   3. This notice may not be removed or altered from any source distribution.
   René Nyffenegger rene.nyffenegger@adp-gmbh.ch
*/
#include "Font.h"
Font::Font(STD_STR const& name, int size, bool bold, bool italic, bool underlined) {
  font_ = ::CreateFont(size, 0, 0, 0, bold? FW_BOLD : FW_NORMAL, italic, underlined, false,
      DEFAULT_CHARSET,
      OUT_DEFAULT_PRECIS,
      CLIP_DEFAULT_PRECIS,
      DEFAULT_QUALITY,
      FF_DONTCARE,
      name.c_str());
  if (!font_) {
    throw "Couldn't create font";
  }
}
Font::~Font() {
  ::DeleteObject(font_);
}

转载于:https://www.cnblogs.com/honeynm/p/4695864.html

你可能感兴趣的文章
初识HTML
查看>>
mysql locktables
查看>>
django(一)验证码
查看>>
day06 Java基础
查看>>
do...while和while...do的两种场景比较
查看>>
iOS被开发者遗忘在角落的NSException-其实它很强大
查看>>
WPF学习(1) – XAML
查看>>
集合类接口IEnumerable,IEnumerator,ICollection,IList,IDictionary理解
查看>>
Entity Framework返回IEnumerable还是IQueryable?
查看>>
零基础http代理http完美代理访问
查看>>
数组与内存控制笔记
查看>>
关于 Go2Shell (Go2Shell 可以在 Finder 中打开当前目录的终端窗口,是一个对开发者来说非常有用的App)...
查看>>
2008年我买了一本书 书名叫“PHP 6”
查看>>
管道,数据共享,进程池
查看>>
UITableView beginUpdate和endUpdate使用的前提
查看>>
MySQL数据类型
查看>>
Java基础--面向对象编程4(多态)
查看>>
c++第二天
查看>>
【原】迎接微信winphone 5.0 版本的IE10样式兼容
查看>>
linux wget 命令用法详解(附实例说明)
查看>>