├── .editorconfig ├── .gitignore ├── .texlife.profile ├── .travis.yml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── images ├── programming_haiku_vol1-001.png ├── programming_haiku_vol1-015.png ├── programming_haiku_vol1-022.png ├── programming_haiku_vol1-171.png └── programming_with_haiku_logo.png ├── include ├── css │ └── style.css ├── haiku │ └── haikulogov2.png ├── latex │ ├── after_body.tex │ ├── before_body.tex │ ├── chapter_break.tex │ └── preamble.tex └── pandoc │ ├── eisvogel.latex │ └── eisvogel_mod.latex ├── psd └── volume1-cover.psd ├── volume1 ├── Makefile ├── Sources │ ├── 15ClickMe │ │ ├── App.cpp │ │ ├── App.h │ │ ├── ClickMe.pld │ │ ├── MainWindow.cpp │ │ └── MainWindow.h │ ├── 17MenuColors │ │ ├── App.cpp │ │ ├── App.h │ │ ├── MainWindow.cpp │ │ ├── MainWindow.h │ │ ├── MenuColors │ │ └── MenuColors.pld │ ├── 18ListTitle │ │ ├── App.cpp │ │ ├── App.h │ │ ├── ListTitle.pld │ │ ├── MainWindow.cpp │ │ └── MainWindow.h │ ├── 19Emo │ │ ├── App.cpp │ │ ├── App.h │ │ ├── Emo.pld │ │ ├── MainWindow.cpp │ │ ├── MainWindow.h │ │ ├── PictureView.cpp │ │ ├── PictureView.h │ │ └── Resources.rsrc │ ├── 20ListDir │ │ ├── App.cpp │ │ └── ListDir.pld │ ├── 22HaikuFortune │ │ ├── App.cpp │ │ ├── App.h │ │ ├── FortuneFunctions.cpp │ │ ├── FortuneFunctions.h │ │ ├── HaikuFortune.pld │ │ ├── HaikuFortune.rsrc │ │ ├── HaikuFortune16.png │ │ ├── HaikuFortune32.png │ │ ├── MainWindow.cpp │ │ ├── MainWindow.h │ │ └── Resources.rsrc │ └── DropMe │ │ ├── App.cpp │ │ ├── App.h │ │ ├── DropMe │ │ ├── DropMe.pld │ │ ├── DropView.cpp │ │ ├── DropView.h │ │ ├── MainWindow.cpp │ │ └── MainWindow.h ├── chapters │ ├── answers.Md │ ├── conclusions.Md │ ├── disclaimer.Md │ ├── lesson01.Md │ ├── lesson02.Md │ ├── lesson03.Md │ ├── lesson04.Md │ ├── lesson05.Md │ ├── lesson06.Md │ ├── lesson07.Md │ ├── lesson08.Md │ ├── lesson09.Md │ ├── lesson10.Md │ ├── lesson11.Md │ ├── lesson12.Md │ ├── lesson13.Md │ ├── lesson14.Md │ ├── lesson15.Md │ ├── lesson16.Md │ ├── lesson17.Md │ ├── lesson18.Md │ ├── lesson19.Md │ ├── lesson20.Md │ ├── lesson21.Md │ ├── lesson22.Md │ └── lesson23.Md ├── images │ ├── cc-by-nc-sa.png │ ├── cover.png │ ├── filetypes.png │ ├── myfirstappshot.png │ ├── paladin2.png │ └── quickres.png └── metadata.yml └── volume2 ├── Makefile ├── Programming with Haiku -- GDB.odt ├── Programming with Haiku Lesson 1.odt ├── Programming with Haiku Lesson 10.odt ├── Programming with Haiku Lesson 11.odt ├── Programming with Haiku Lesson 12.odt ├── Programming with Haiku Lesson 13.odt ├── Programming with Haiku Lesson 14.odt ├── Programming with Haiku Lesson 15.odt ├── Programming with Haiku Lesson 16.odt ├── Programming with Haiku Lesson 17.odt ├── Programming with Haiku Lesson 18.odt ├── Programming with Haiku Lesson 19.odt ├── Programming with Haiku Lesson 2.odt ├── Programming with Haiku Lesson 20.odt ├── Programming with Haiku Lesson 21.odt ├── Programming with Haiku Lesson 22.odt ├── Programming with Haiku Lesson 23.odt ├── Programming with Haiku Lesson 24.odt ├── Programming with Haiku Lesson 25.odt ├── Programming with Haiku Lesson 26.odt ├── Programming with Haiku Lesson 27 (unfinished).odt ├── Programming with Haiku Lesson 28 (unfinished).odt ├── Programming with Haiku Lesson 3.odt ├── Programming with Haiku Lesson 4.odt ├── Programming with Haiku Lesson 5.odt ├── Programming with Haiku Lesson 6.odt ├── Programming with Haiku Lesson 7.odt ├── Programming with Haiku Lesson 8.odt ├── Programming with Haiku Lesson 9.odt ├── Programming with Haiku Unit 1 Review.odt ├── Programming with Haiku Unit 2 Review.odt ├── Programming with Haiku Unit 3 Review.odt ├── Scripting Suites.txt ├── Sources ├── AutoTextControl.cpp ├── AutoTextControl.h ├── BQuery Example.cpp ├── ColorWell - Draft.cpp ├── ColorWell - Draft.h ├── ColorWell - L17.cpp ├── ColorWell - L17.h ├── ColorWell - L19.cpp ├── ColorWell - L19.h ├── ColorWell - L20.cpp ├── ColorWell - L20.h ├── DragView.cpp ├── DragView.h ├── FontDemo │ ├── App.cpp │ ├── App.h │ ├── FontDemo1.pld │ ├── MainView.cpp │ ├── MainView.h │ ├── MainWindow.cpp │ └── MainWindow.h ├── GetEmailName.cpp ├── LibWindow.cpp ├── LibWindow.h ├── Push BQuery Example.cpp ├── QuickEdit - L22 │ ├── App.cpp │ ├── App.h │ ├── MainWindow.cpp │ ├── MainWindow.h │ ├── QuickEdit L22.pld │ ├── QuickEdit.pld │ └── Resources.rsrc ├── QuickEdit - L23 │ ├── App.cpp │ ├── App.h │ ├── EditView.cpp │ ├── EditView.h │ ├── MainWindow.cpp │ ├── MainWindow.h │ ├── QuickEdit.pld │ └── Resources.rsrc ├── ReadProject.cpp ├── Resource Template.rdef ├── Scripting Explorer │ ├── .hg │ │ ├── 00changelog.i │ │ ├── branchheads.cache │ │ ├── dirstate │ │ ├── last-message.txt │ │ ├── requires │ │ ├── store │ │ │ ├── 00changelog.i │ │ │ ├── 00manifest.i │ │ │ ├── data │ │ │ │ ├── .hgignore.i │ │ │ │ ├── _prop_dump.cpp.i │ │ │ │ ├── _prop_dump.h.i │ │ │ │ ├── _script_view.cpp.i │ │ │ │ ├── _script_view.h.i │ │ │ │ ├── _script_window.cpp.i │ │ │ │ ├── _script_window.h.i │ │ │ │ ├── _script_world.cpp.i │ │ │ │ ├── _script_world.h.i │ │ │ │ ├── _script_world.pld.i │ │ │ │ ├── _script_world.rsrc.i │ │ │ │ ├── _send_panel.cpp.i │ │ │ │ └── _send_panel.h.i │ │ │ ├── fncache │ │ │ └── undo │ │ ├── tags.cache │ │ ├── undo.branch │ │ ├── undo.desc │ │ └── undo.dirstate │ ├── .hgignore │ ├── PropDump.cpp │ ├── PropDump.h │ ├── ScriptView.cpp │ ├── ScriptView.h │ ├── ScriptWindow.cpp │ ├── ScriptWindow.h │ ├── ScriptWorld.cpp │ ├── ScriptWorld.pld │ ├── ScriptWorld.rsrc │ ├── SendPanel.cpp │ └── SendPanel.h ├── SetMime.cpp ├── SetPermissions.cpp ├── TrackerAddon.cpp ├── TrackerAddon.h ├── TrackerAddon.pld ├── TrackerAddon.rsrc ├── TranslatorDemo │ ├── .hg │ │ ├── 00changelog.i │ │ ├── cache │ │ │ └── branchheads │ │ ├── dirstate │ │ ├── last-message.txt │ │ ├── requires │ │ ├── store │ │ │ ├── 00changelog.i │ │ │ ├── 00manifest.i │ │ │ ├── data │ │ │ │ ├── _app.cpp.i │ │ │ │ ├── _app.h.i │ │ │ │ ├── _bitmap_view.cpp.i │ │ │ │ ├── _bitmap_view.h.i │ │ │ │ ├── _bitmap_window.cpp.i │ │ │ │ ├── _bitmap_window.h.i │ │ │ │ ├── _main_window.cpp.i │ │ │ │ ├── _main_window.h.i │ │ │ │ └── _translator_demo.pld.i │ │ │ ├── fncache │ │ │ └── undo │ │ ├── undo.branch │ │ ├── undo.desc │ │ └── undo.dirstate │ ├── App.cpp │ ├── App.h │ ├── BitmapView.cpp │ ├── BitmapView.h │ ├── BitmapWindow.cpp │ ├── BitmapWindow.h │ ├── MainWindow.cpp │ ├── MainWindow.h │ └── TranslatorDemo.pld ├── overlayimage │ ├── .svn │ │ ├── entries │ │ └── text-base │ │ │ ├── Jamfile.svn-base │ │ │ ├── OverlayApp.cpp.svn-base │ │ │ ├── OverlayApp.h.svn-base │ │ │ ├── OverlayImage.rdef.svn-base │ │ │ ├── OverlayView.cpp.svn-base │ │ │ ├── OverlayView.h.svn-base │ │ │ ├── OverlayWindow.cpp.svn-base │ │ │ └── OverlayWindow.h.svn-base │ ├── Jamfile │ ├── OverlayApp.cpp │ ├── OverlayApp.h │ ├── OverlayImage.rdef │ ├── OverlayView.cpp │ ├── OverlayView.h │ ├── OverlayWindow.cpp │ └── OverlayWindow.h ├── printres.cpp └── scripting_code_samples.cpp ├── chapters ├── disclaimer.Md └── lesson01.Md ├── images ├── ColorWellDemo1.png ├── FileType.png ├── FontDemo1.png ├── Icon-O-Matic.png ├── QuickRes.png ├── ResEdit.png ├── cc-by-nc-sa.png └── cover.png ├── metadata.yml ├── rc help.txt └── xres help.txt /.editorconfig: -------------------------------------------------------------------------------- 1 | # See http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = space 9 | trim_trailing_whitespace = true 10 | 11 | [*.{r,R,md,Rmd}] 12 | indent_size = 2 13 | 14 | [{NEWS.md,DESCRIPTION,LICENSE,CHANGELOG}] 15 | max_line_length = 80 16 | 17 | [Makefile] 18 | indent_style = tab 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.log 3 | .DS_Store 4 | ~*.odt 5 | -------------------------------------------------------------------------------- /.texlife.profile: -------------------------------------------------------------------------------- 1 | selected_scheme scheme-basic 2 | instopt_adjustpath 1 3 | collection-basic 1 4 | collection-bibtexextra 0 5 | collection-fontsextra 0 6 | collection-fontsrecommended 1 7 | collection-langchinese 0 8 | collection-latex 1 9 | collection-latexextra 0 10 | collection-latexrecommended 1 11 | collection-mathscience 0 12 | collection-xetex 1 13 | tlpdbopt_autobackup 0 14 | tlpdbopt_install_docfiles 0 15 | tlpdbopt_install_srcfiles 0 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: linux 2 | dist: bionic 3 | language: java 4 | before_install: 5 | # default pandoc is too old -> install a newer version manually 6 | - PANDOC_VERSION="2.9.2" 7 | - pandoc_deb="pandoc-${PANDOC_VERSION}-1-amd64.deb" 8 | - wget "https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/${pandoc_deb}" 9 | - sudo dpkg -i ${pandoc_deb} 10 | - rm ${pandoc_deb} 11 | 12 | # default textlife from apt-get is too old 13 | # install the latest texlife version manually 14 | - REMOTE="http://mirror.ctan.org/systems/texlive/tlnet" 15 | - INSTALL="/tmp/install-texlive" 16 | - mkdir -p $INSTALL 17 | - curl -sSL $REMOTE/install-tl-unx.tar.gz | tar -xzv -C $INSTALL --strip-components=1 18 | - sudo $INSTALL/install-tl -no-gui -profile .texlife.profile 19 | - VERSION=$($INSTALL/install-tl --version | grep 'version' | grep -o '[0-9]\{4\}') 20 | - PLATFORM=$($INSTALL/install-tl --print-platform) 21 | - TEXLIVE_DIR="/usr/local/texlive/${VERSION}" 22 | - TEXBIN="/usr/local/texlive/${VERSION}/bin/${PLATFORM}" 23 | - export "PATH=$TEXBIN:$PATH" 24 | 25 | # initialization for tlmgr 26 | - sudo apt-get install xzdec 27 | - tlmgr init-usertree 28 | 29 | # install pdftoppm for rendering the PDFs 30 | - sudo apt-get install poppler-utils 31 | 32 | # for executing python based pandoc filters install python and pip 33 | - sudo apt-get install python3 34 | - sudo apt-get install python3-pip 35 | - sudo pip3 install --upgrade setuptools 36 | - sudo pip3 install wheel 37 | 38 | # for converting to mobi 39 | - sudo apt-get install calibre 40 | 41 | # install python filters 42 | - pip3 install pandoc-latex-environment 43 | 44 | 45 | - sudo chown -hR $(whoami) "$TEXLIVE_DIR" 46 | # packages specified in the template 47 | - tlmgr install adjustbox background bidi csquotes footmisc footnotebackref fvextra mdframed pagecolor sourcecodepro sourcesanspro titling ulem upquote xurl 48 | 49 | # trial and error 50 | - tlmgr install letltxmacro zref everypage framed collectbox 51 | 52 | # packages needed for the template 53 | - tlmgr install xecjk filehook unicode-math ucharcat ly1 mweights mdframed needspace 54 | 55 | # packages needed for the books 56 | - tlmgr install awesomebox fontawesome5 newunicodechar 57 | script: 58 | - make -C volume1 all 59 | - make -C volume1 png 60 | deploy: 61 | provider: releases 62 | api_key: 63 | secure: "BAXn+qMv1FR0bfpB5pLNJmkN82Xi13CLyOwE/+1Ua3oDO7f3NsPLULowGIZsV6jU8qBlXQPOD7qnE0Ww0VEDvxNtzU/5TymkRboTFcoC3lcSOKf0q6bgN9R8NVBzZaj3jK65+peGOGtaoXOkiqAZF6qQd415iCen5/kIcH+R5EszffaOGfnz0NJsSf39fSHKPB3LvCHAE6n6Y3v8x+NGvWDald0iwVtYMpL9YbcCtXthQRi0+BggRtstvk+97SgRPa1AwaRT5NIzYLESi9Jm/gEYf3QXwmv+qgiK3D3PPh6YGUfTGxu1RpSNK4R4e1F6zbmyYRQR07Z6AHt0lSb0XVtxokT7iMsK5LddEbsE+aNydfztt0r6Gx2TrisF4LqYpT16kJg3hpIIjBEZV9ulqdq0D/oqtP35wyc7yr7ThGgfnyCrjs+14xMzE4HwKEZwWCPltyBiHeqQbILvA3yag6Wp08t/y6/3gtX7jMSUTi6boMoZFB0ziTA/8t99Jmt9xrsvebvgM0SUO+fycZOIqNaHGpEd9fg7Y3dgIi4D/oNyuiELcTyX1f4EV8i9jGaB/ldimujx+l7oh/6ElxHhgLDGghHvrcIZBFvX0RaHTJS7uX482jPtyj+z/zyPWFW2/PtaoBO4gX3LcxTpxdMppDb+YBsbJ+7+xrKzEOWKbEY=" 64 | file_glob: true 65 | file: 66 | - "$TRAVIS_BUILD_DIR/volume1/build/**/*.{epub,html.tar.gz,mobi,pdf}" 67 | skip_cleanup: true 68 | on: 69 | tags: true 70 | repo: theclue/programming-with-haiku 71 | all_branches: true 72 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ivotron/pandoc 2 | ENV TZ="Europe/Rome" 3 | 4 | RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \ 5 | && apt-get update \ 6 | && apt-get install -y --no-install-recommends tzdata curl calibre \ 7 | && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \ 8 | && dpkg-reconfigure --frontend noninteractive tzdata \ 9 | && apt-get clean \ 10 | && rm -rf /var/lib/apt/lists/ 11 | 12 | WORKDIR /app 13 | COPY . . 14 | 15 | CMD ["make", "all"] 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This work is licensed under the 2 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 3 | 4 | To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ 5 | or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BUILD = build 2 | MAKEFILE = Makefile 3 | OUTPUT_FILENAME = ProgrammingHaiku 4 | METADATA = metadata.yml 5 | CHAPTERS = chapters/*.md 6 | TOC = --toc --toc-depth=2 7 | IMAGES_FOLDER = images 8 | IMAGES = $(IMAGES_FOLDER)/* 9 | COVER_IMAGE = $(IMAGES_FOLDER)/cover.png 10 | LATEX_CLASS = report 11 | MATH_FORMULAS = --webtex 12 | CSS_FILE = style.css 13 | CSS_ARG = --css=$(CSS_FILE) 14 | METADATA_ARG = --metadata-file=$(METADATA) 15 | ARGS = $(TOC) $(MATH_FORMULAS) $(CSS_ARG) $(METADATA_ARG) 16 | 17 | CDIR := . 18 | ODIR := . 19 | ADOC_SRCS := $(wildcard $(CDIR)/*.adoc) 20 | ADOC_OBJS := $(SRCS:$(CDIR)/%.adoc=$(ODIR)/%.xml) 21 | 22 | all: book 23 | 24 | book: epub html pdf mobi 25 | 26 | clean: 27 | rm -r $(BUILD) 28 | 29 | DOCBOOKS := lesson1.adoc lesson2.adoc lessob3.adic 30 | 31 | docbooks: $(OBJECTS) 32 | 33 | 34 | %.xml : %.adoc 35 | asciidoc -b docbook lesson1.adoc 36 | 37 | mobi: $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi 38 | 39 | epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub 40 | 41 | html: $(BUILD)/html/$(OUTPUT_FILENAME).html 42 | 43 | pdf: $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf 44 | 45 | $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi: epub 46 | mkdir -p $(BUILD)/mobi 47 | ebook-convert $(BUILD)/epub/$(OUTPUT_FILENAME).epub $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi 48 | 49 | $(BUILD)/epub/$(OUTPUT_FILENAME).epub: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES) \ 50 | $(COVER_IMAGE) 51 | mkdir -p $(BUILD)/epub 52 | pandoc $(ARGS) --epub-cover-image=$(COVER_IMAGE) -o $@ $(CHAPTERS) 53 | 54 | $(BUILD)/html/$(OUTPUT_FILENAME).html: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES) 55 | mkdir -p $(BUILD)/html 56 | pandoc $(ARGS) --standalone --to=html5 -o $@ $(CHAPTERS) 57 | cp -R $(IMAGES_FOLDER)/ $(BUILD)/html/$(IMAGES_FOLDER)/ 58 | cp $(CSS_FILE) $(BUILD)/html/$(CSS_FILE) 59 | 60 | $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf: $(MAKEFILE) $(METADATA) $(CHAPTERS) $(CSS_FILE) $(IMAGES) 61 | mkdir -p $(BUILD)/pdf 62 | pandoc $(ARGS) -V documentclass=$(LATEX_CLASS) -o $@ $(CHAPTERS) 63 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/theclue/programming-with-haiku.svg?branch=master)](https://travis-ci.org/theclue/programming-with-haiku) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/38bf00511e0a4f7c90974d6b5a177672)](https://www.codacy.com/manual/theclue/programming-with-haiku?utm_source=github.com&utm_medium=referral&utm_content=theclue/programming-with-haiku&utm_campaign=Badge_Grade) [![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/theclue/programming-with-haiku)](https://github.com/theclue/programming-with-haiku/pulls?q=is%3Apr+is%3Aclosed) [![GitHub Release Date](https://img.shields.io/github/release-date/theclue/programming-with-haiku)](https://github.com/theclue/programming-with-haiku/releases) 2 | 3 | *** 4 | 5 |

6 | 7 | These are the original classics from Jon Yoder, in a new set of open formats. 8 | 9 | ## Showcases 10 | 11 | ![Cover](https://github.com/theclue/programming-with-haiku/raw/master/images/programming_haiku_vol1-001.png) ![PDF Example 1](https://github.com/theclue/programming-with-haiku/raw/master/images/programming_haiku_vol1-015.png) ![PDF Example 2](https://github.com/theclue/programming-with-haiku/raw/master/images/programming_haiku_vol1-022.png) ![PDF Example 3](https://github.com/theclue/programming-with-haiku/raw/master/images/programming_haiku_vol1-171.png) 12 | -------------------------------------------------------------------------------- /images/programming_haiku_vol1-001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/images/programming_haiku_vol1-001.png -------------------------------------------------------------------------------- /images/programming_haiku_vol1-015.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/images/programming_haiku_vol1-015.png -------------------------------------------------------------------------------- /images/programming_haiku_vol1-022.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/images/programming_haiku_vol1-022.png -------------------------------------------------------------------------------- /images/programming_haiku_vol1-171.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/images/programming_haiku_vol1-171.png -------------------------------------------------------------------------------- /images/programming_with_haiku_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/images/programming_with_haiku_logo.png -------------------------------------------------------------------------------- /include/haiku/haikulogov2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/include/haiku/haikulogov2.png -------------------------------------------------------------------------------- /include/latex/after_body.tex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/include/latex/after_body.tex -------------------------------------------------------------------------------- /include/latex/before_body.tex: -------------------------------------------------------------------------------- 1 | % you may need to leave a few empty pages before the dedication page 2 | 3 | \cleardoublepage\newpage 4 | \thispagestyle{empty} 5 | 6 | \begin{center} 7 | To Melody, for putting up with me. 8 | 9 | \end{center} 10 | 11 | \setlength{\abovedisplayskip}{-5pt} 12 | \setlength{\abovedisplayshortskip}{-5pt} 13 | 14 | \cleardoublepage -------------------------------------------------------------------------------- /include/latex/chapter_break.tex: -------------------------------------------------------------------------------- 1 | \usepackage{sectsty} 2 | \sectionfont{\clearpage} -------------------------------------------------------------------------------- /include/latex/preamble.tex: -------------------------------------------------------------------------------- 1 | \usepackage{booktabs} 2 | \usepackage{longtable} 3 | 4 | \usepackage{awesomebox} 5 | 6 | \definecolor{errorboxcolor}{RGB}{188,0,0} 7 | \definecolor{bughuntboxcolor}{RGB}{188,0,0} 8 | \definecolor{warningboxcolor}{RGB}{188,50,0} 9 | 10 | \newenvironment{questionblock} 11 | {\begin{awesomeblock}[black]{\aweboxrulewidth}{\faQuestion[regular]}{black}} 12 | {\end{awesomeblock}} 13 | 14 | \newenvironment{assignmentblock} 15 | {\begin{awesomeblock}[black]{\aweboxrulewidth}{\faPen[regular]}{black}} 16 | {\end{awesomeblock}} 17 | 18 | \newenvironment{toughblock} 19 | {\begin{awesomeblock}[black]{\aweboxrulewidth}{\faCogs[regular]}{black}} 20 | {\end{awesomeblock}} 21 | 22 | \newenvironment{errorblock} 23 | {\begin{awesomeblock}[errorboxcolor]{\aweboxrulewidth}{\faTimes[regular]}{errorboxcolor}} 24 | {\end{awesomeblock}} 25 | 26 | \newenvironment{shellerrorblock} 27 | {\begin{awesomeblock}[errorboxcolor]{\aweboxrulewidth}{\faTimes[regular]}{errorboxcolor}\texttt\bgroup} 28 | {\egroup\end{awesomeblock}} 29 | 30 | \newenvironment{bughuntblock} 31 | {\begin{awesomeblock}[bughuntboxcolor]{\aweboxrulewidth}{\faBug[regular]}{bughuntboxcolor}\texttt\bgroup} 32 | {\egroup\end{awesomeblock}} 33 | 34 | \newenvironment{bugwarningblock} 35 | {\begin{awesomeblock}[warningboxcolor]{\aweboxrulewidth}{\faBug[regular]}{warningboxcolor}} 36 | {\end{awesomeblock}} 37 | 38 | 39 | \usepackage{framed,color} 40 | 41 | % tweak deafult fonts 42 | \usepackage{fontspec} 43 | \usepackage{xltxtra,xunicode} 44 | \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase} 45 | 46 | % Place links inline 47 | \let\oldhref\href 48 | \renewcommand{\href}[2]{#2 (\url{#1})} 49 | 50 | \renewenvironment{quote}% 51 | {\list{}{\leftmargin=0.5in\rightmargin=0.5in}\item[]\begin{itshape}}% 52 | {\end{itshape}\endlist} 53 | 54 | % No widow lines 55 | \widowpenalty=10000 56 | \clubpenalty=10000 57 | 58 | \urlstyle{tt} 59 | 60 | 61 | \frontmatter 62 | -------------------------------------------------------------------------------- /psd/volume1-cover.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/psd/volume1-cover.psd -------------------------------------------------------------------------------- /volume1/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY = docbooks clean 2 | 3 | BUILD = build 4 | MAKEFILE = Makefile 5 | OUTPUT_FILENAME = Jon_Yoder_-_Programming_with_Haiku_Volume_1 6 | 7 | INCLUDE_DIR = ../include 8 | IMAGES_DIR = images 9 | IMAGES = $(IMAGES_DIR)/* 10 | COVER_IMAGE = $(IMAGES_DIR)/cover.png 11 | 12 | METADATA = metadata.yml 13 | TOC = --toc --toc-depth=2 -V toc-title='Table of contents' -V toc-own-page:true 14 | CSS_FILE = $(INCLUDE_DIR)/css/style.css 15 | CSS_ARG = --css=$(CSS_FILE) 16 | METADATA_ARG = --metadata-file=$(METADATA) 17 | MATH_FORMULAS = --webtex 18 | 19 | PDF_ENGINE=xelatex 20 | ARGS = $(MATH_FORMULAS) $(CSS_ARG) $(METADATA_ARG) 21 | 22 | MARKDOWN_FORMAT = markdown-pipe_tables+backtick_code_blocks+fancy_lists+table_captions+smart+fenced_divs 23 | 24 | CHAPTERS_DIR = ./chapters 25 | CHAPTERS := disclaimer.Md lesson01.Md lesson02.Md lesson03.Md lesson04.Md \ 26 | lesson05.Md lesson06.Md lesson07.Md lesson08.Md \ 27 | lesson09.Md lesson10.Md lesson11.Md lesson12.Md \ 28 | lesson13.Md lesson14.Md lesson15.Md lesson16.Md \ 29 | lesson17.Md lesson18.Md lesson19.Md lesson20.Md \ 30 | lesson21.Md lesson22.Md lesson23.Md answers.Md conclusions.Md 31 | 32 | CHAPTERS_TARGETS = $(addprefix $(CHAPTERS_DIR)/,$(CHAPTERS)) 33 | 34 | all: book 35 | 36 | book: epub html pdf mobi 37 | 38 | clean: 39 | rm -rf $(BUILD) 40 | 41 | markdown: $(BUILD)/markdown/$(OUTPUT_FILENAME).Md 42 | 43 | mobi: $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi 44 | 45 | epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub 46 | 47 | html: $(BUILD)/html/$(OUTPUT_FILENAME).html.tar.gz 48 | 49 | pdf: $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf 50 | 51 | png: pdf 52 | mkdir -p $(BUILD)/png 53 | pdftoppm -png -r 42 -aa yes $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf $(BUILD)/png/$(OUTPUT_FILENAME) 54 | 55 | $(BUILD)/markdown/$(OUTPUT_FILENAME).Md: $(CHAPTERS_TARGETS) 56 | mkdir -p $(BUILD)/markdown 57 | mdmerge $(CHAPTERS_TARGETS) -o $(BUILD)/markdown/$(OUTPUT_FILENAME).Md 58 | 59 | $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi: epub 60 | mkdir -p $(BUILD)/mobi 61 | ebook-convert $(BUILD)/epub/$(OUTPUT_FILENAME).epub $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi 62 | 63 | $(BUILD)/epub/$(OUTPUT_FILENAME).epub: $(MAKEFILE) $(METADATA) $(CHAPTERS_TARGETS) $(CSS_FILE) $(IMAGES) \ 64 | $(COVER_IMAGE) 65 | mkdir -p $(BUILD)/epub 66 | pandoc $(ARGS) --epub-cover-image=$(COVER_IMAGE) -f $(MARKDOWN_FORMAT) -t epub -o $@ -s $(CHAPTERS_TARGETS) 67 | 68 | $(BUILD)/html/$(OUTPUT_FILENAME).html.tar.gz : $(MAKEFILE) $(METADATA) $(CHAPTERS_TARGETS) $(CSS_FILE) $(IMAGES) 69 | mkdir -p $(BUILD)/html_tmp 70 | mkdir -p $(BUILD)/html 71 | pandoc $(ARGS) --standalone --to=html5 -o $(BUILD)/html_tmp/$(OUTPUT_FILENAME).html $(CHAPTERS_TARGETS) 72 | cp -R $(IMAGES_DIR)/ $(BUILD)/html_tmp/$(IMAGES_DIR)/ 73 | tar -zcvf $(BUILD)/html/$(OUTPUT_FILENAME).html.tar.gz -C $(BUILD)/html_tmp . 74 | rm -r $(BUILD)/html_tmp 75 | 76 | $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf: $(CHAPTERS_TARGETS) $(CSS_FILE) 77 | mkdir -p $(BUILD)/markdown 78 | mkdir -p $(BUILD)/pdf 79 | pandoc $(ARGS) \ 80 | $(TOC) \ 81 | --template=$(INCLUDE_DIR)/pandoc/eisvogel.latex \ 82 | --metadata=abstract:" " \ 83 | -V geometry:a4paper -V geometry:"left=2.54cm,right=2.54cm,top=1.91cm,bottom=1.91cm" \ 84 | -V titlepage:true -V titlepage-color:"FFFFFF" -V titlepage-rule-height:0 -V titlepage-rule-color:"d8dbdc" \ 85 | -V titlepage-background:$(COVER_IMAGE) \ 86 | -V title:"" -V subtitle:"" -V author:"" \ 87 | -V header-left:"Programming with Haiku" -V header-right:"Volume 1" \ 88 | -V footer-left:"Jon Yoder" \ 89 | -V links-as-notes:true \ 90 | -V lot:true \ 91 | -V footnotes-pretty:true \ 92 | --listing -V listings-disable-line-numbers:true \ 93 | -V book:true --top-level-division=chapter \ 94 | --pdf-engine=$(PDF_ENGINE) \ 95 | --include-in-header $(INCLUDE_DIR)/latex/preamble.tex \ 96 | --include-before-body $(INCLUDE_DIR)/latex/before_body.tex \ 97 | --include-after-body $(INCLUDE_DIR)/latex/after_body.tex \ 98 | --filter pandoc-latex-environment \ 99 | --number-offset=1 \ 100 | -f $(MARKDOWN_FORMAT) \ 101 | -s $(CHAPTERS_TARGETS) \ 102 | -o $@ 103 | 104 | %.xml : %.adoc 105 | asciidoctor -v -d book -b docbook -s $< -o $@ 106 | 107 | $(CHAPTERS_DIR)/%.Md : %.xml 108 | mkdir -p $(CHAPTERS_DIR) 109 | pandoc --highlight-style=pygments --wrap=none -f docbook -t $(MARKDOWN_FORMAT) --shift-heading-level-by=1 $< -o $@ 110 | 111 | -------------------------------------------------------------------------------- /volume1/Sources/15ClickMe/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-ClickMe") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume1/Sources/15ClickMe/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume1/Sources/15ClickMe/ClickMe.pld: -------------------------------------------------------------------------------- 1 | NAME=ClickMe 2 | TARGETNAME=ClickMe 3 | GROUP=Source Files 4 | EXPANDGROUP=yes 5 | SOURCEFILE=App.cpp 6 | DEPENDENCY=/boot/home/projects/ButtonDemo/App.cpp| /boot/home/projects/ButtonDemo/App.h| /boot/home/projects/ButtonDemo/MainWindow. 7 | SOURCEFILE=MainWindow.cpp 8 | DEPENDENCY=/boot/home/projects/ButtonDemo/MainWindow.cpp| /boot/home/projects/ButtonDemo/MainWindow. 9 | LOCALINCLUDE=/boot/home/projects/ButtonDemo/. 10 | SYSTEMINCLUDE=/boot/develop/headers/be 11 | SYSTEMINCLUDE=/boot/develop/headers/cpp 12 | SYSTEMINCLUDE=/boot/develop/headers/posix 13 | SYSTEMINCLUDE=/boot/home/config/include 14 | LIBRARY=/boot/develop/lib/x86/libroot.so 15 | LIBRARY=/boot/develop/lib/x86/libbe.so 16 | LIBRARY=/boot/system/lib/libsupc++.so 17 | RUNARGS= 18 | CCDEBUG=no 19 | CCPROFILE=no 20 | CCOPSIZE=no 21 | CCOPLEVEL=0 22 | CCTARGETTYPE=0 23 | CCEXTRA= 24 | LDEXTRA= 25 | -------------------------------------------------------------------------------- /volume1/Sources/15ClickMe/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | // Button.h adds the class definiton for the BButton control 4 | #include 5 | 6 | // The BView class is the generic class for creating controls and drawing things inside 7 | // a window 8 | #include 9 | 10 | // The BString class is a phenomenally useful class which eliminates 11 | // almost all hassle associated with manipulating strings. 12 | #include 13 | 14 | // This defines the identifier for the message that our button will send. The letters 15 | // inside the single quotes are translated into an integer. The value for M_BUTTON_CLICKED 16 | // is arbitrary, so as long as it's unique, it's not too important what it is. 17 | enum 18 | { 19 | M_BUTTON_CLICKED = 'btcl' 20 | }; 21 | 22 | 23 | MainWindow::MainWindow(void) 24 | : BWindow(BRect(100,100,300,200),"ClickMe",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | 25 | B_QUIT_ON_WINDOW_CLOSE), 26 | fCount(0) 27 | { 28 | // Create a button in pretty much the same way that we did the label in 29 | // the last lesson. The BRect() call inside the BButton constructor is a quick 30 | // shortcut that eliminates creating a variable. 31 | BButton *button = new BButton(BRect(10,10,11,11),"button","Click Me!", 32 | new BMessage(M_BUTTON_CLICKED)); 33 | 34 | // Like with last lesson's label, make the button choose how big it should be. 35 | button->ResizeToPreferred(); 36 | 37 | // Add our button to the window 38 | AddChild(button); 39 | } 40 | 41 | 42 | void 43 | MainWindow::MessageReceived(BMessage *msg) 44 | { 45 | // The way that BMessages are identified is by the public property 'what'. 46 | switch (msg->what) 47 | { 48 | // If the message was the one sent to the window by the button 49 | case M_BUTTON_CLICKED: 50 | { 51 | fCount++; 52 | 53 | BString labelString("Clicks: "); 54 | 55 | // This adds the value of fCount to the end of labelString. More on this later. 56 | labelString << fCount; 57 | 58 | // Set the window's title to the new string we've made 59 | SetTitle(labelString.String()); 60 | break; 61 | } 62 | default: 63 | { 64 | // If the message doesn't match one of the ones we explicitly define, it must 65 | // be some sort of system message, so we will call the version of MessageReceived() 66 | // created for BWindow so that it can handle them. THIS IS REQUIRED if you want 67 | // your window to act the way that you expect it to. 68 | BWindow::MessageReceived(msg); 69 | break; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /volume1/Sources/15ClickMe/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | class MainWindow : public BWindow 7 | { 8 | public: 9 | MainWindow(void); 10 | 11 | // We are implementing the virtual BWindow method MessageReceived so that we 12 | // can handle the message that the button will send to the window 13 | void MessageReceived(BMessage *msg); 14 | 15 | private: 16 | // This property will hold the number of times the button has been clicked. 17 | int32 fCount; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /volume1/Sources/17MenuColors/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-MenuColors") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume1/Sources/17MenuColors/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume1/Sources/17MenuColors/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | enum 9 | { 10 | M_SET_COLOR_RED = 'sred', 11 | M_SET_COLOR_GREEN = 'sgrn', 12 | M_SET_COLOR_BLUE = 'sblu', 13 | M_SET_COLOR_BLACK = 'sblk' 14 | }; 15 | 16 | MainWindow::MainWindow(void) 17 | : BWindow(BRect(100,100,500,400),"MenuColors",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | 18 | B_QUIT_ON_WINDOW_CLOSE) 19 | { 20 | BRect r(Bounds()); 21 | r.bottom = 20; 22 | 23 | BMenuBar *menuBar = new BMenuBar(r,"menubar"); 24 | AddChild(menuBar); 25 | 26 | BMenu *menu = new BMenu("Colors"); 27 | menu->AddItem(new BMenuItem("Red",new BMessage(M_SET_COLOR_RED),'R')); 28 | menu->AddItem(new BMenuItem("Green",new BMessage(M_SET_COLOR_GREEN),'G')); 29 | menu->AddItem(new BMenuItem("Blue",new BMessage(M_SET_COLOR_BLUE),'B')); 30 | menu->AddItem(new BMenuItem("Black",new BMessage(M_SET_COLOR_BLACK),'K')); 31 | menuBar->AddItem(menu); 32 | 33 | BView *view = new BView(BRect(100,100,300,200),"colorview",B_FOLLOW_ALL, B_WILL_DRAW); 34 | AddChild(view); 35 | view->SetViewColor(0,0,160); 36 | } 37 | 38 | 39 | void 40 | MainWindow::MessageReceived(BMessage *msg) 41 | { 42 | BView *view = FindView("colorview"); 43 | 44 | switch (msg->what) 45 | { 46 | case M_SET_COLOR_RED: 47 | { 48 | view->SetViewColor(160,0,0); 49 | view->Invalidate(); 50 | break; 51 | } 52 | case M_SET_COLOR_GREEN: 53 | { 54 | view->SetViewColor(0,160,0); 55 | view->Invalidate(); 56 | break; 57 | } 58 | case M_SET_COLOR_BLUE: 59 | { 60 | view->SetViewColor(0,0,160); 61 | view->Invalidate(); 62 | break; 63 | } 64 | case M_SET_COLOR_BLACK: 65 | { 66 | view->SetViewColor(0,0,0); 67 | view->Invalidate(); 68 | break; 69 | } 70 | default: 71 | { 72 | BWindow::MessageReceived(msg); 73 | break; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /volume1/Sources/17MenuColors/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | class MainWindow : public BWindow 7 | { 8 | public: 9 | MainWindow(void); 10 | void MessageReceived(BMessage *msg); 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /volume1/Sources/17MenuColors/MenuColors: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/17MenuColors/MenuColors -------------------------------------------------------------------------------- /volume1/Sources/17MenuColors/MenuColors.pld: -------------------------------------------------------------------------------- 1 | NAME=MenuColors 2 | TARGETNAME=MenuColors 3 | PLATFORM=Zeta 4 | GROUP=Source Files 5 | EXPANDGROUP=yes 6 | SOURCEFILE=App.cpp 7 | DEPENDENCY=/BeOS/develop/projects/Programming Lessons/MenuColors/App.cpp|/BeOS/develop/projects/Programming Lessons/MenuColors/App.h|/BeOS/develop/projects/Programming Lessons/MenuColors/MainWindow.h 8 | SOURCEFILE=MainWindow.cpp 9 | DEPENDENCY=/BeOS/develop/projects/Programming Lessons/MenuColors/MainWindow.cpp|/BeOS/develop/projects/Programming Lessons/MenuColors/MainWindow.h 10 | LOCALINCLUDE=/boot/home/projects/MenuColors/. 11 | SYSTEMINCLUDE=/boot/develop/headers/be 12 | SYSTEMINCLUDE=/boot/develop/headers/cpp 13 | SYSTEMINCLUDE=/boot/develop/headers/posix 14 | SYSTEMINCLUDE=/boot/home/config/include 15 | LIBRARY=/boot/develop/lib/x86/libroot.so 16 | LIBRARY=/boot/develop/lib/x86/libbe.so 17 | RUNARGS= 18 | CCDEBUG=no 19 | CCPROFILE=no 20 | CCOPSIZE=no 21 | CCOPLEVEL=0 22 | CCTARGETTYPE=0 23 | CCEXTRA= 24 | LDEXTRA= 25 | -------------------------------------------------------------------------------- /volume1/Sources/18ListTitle/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-ListColors") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume1/Sources/18ListTitle/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume1/Sources/18ListTitle/ListTitle.pld: -------------------------------------------------------------------------------- 1 | NAME=ListTitle 2 | TARGETNAME=ListTitle 3 | PLATFORM=Zeta 4 | GROUP=Source Files 5 | EXPANDGROUP=yes 6 | SOURCEFILE=App.cpp 7 | DEPENDENCY=/BeOS/develop/projects/Programming Lessons/MenuColors/App.cpp|/BeOS/develop/projects/Programming Lessons/MenuColors/App.h|/BeOS/develop/projects/Programming Lessons/MenuColors/MainWindow.h 8 | SOURCEFILE=MainWindow.cpp 9 | DEPENDENCY=/BeOS/develop/projects/Programming Lessons/MenuColors/MainWindow.cpp|/BeOS/develop/projects/Programming Lessons/MenuColors/MainWindow.h 10 | LOCALINCLUDE=/boot/home/projects/MenuColors/. 11 | SYSTEMINCLUDE=/boot/develop/headers/be 12 | SYSTEMINCLUDE=/boot/develop/headers/cpp 13 | SYSTEMINCLUDE=/boot/develop/headers/posix 14 | SYSTEMINCLUDE=/boot/home/config/include 15 | LIBRARY=/boot/develop/lib/x86/libroot.so 16 | LIBRARY=/boot/develop/lib/x86/libbe.so 17 | RUNARGS= 18 | CCDEBUG=no 19 | CCPROFILE=no 20 | CCOPSIZE=no 21 | CCOPLEVEL=0 22 | CCTARGETTYPE=0 23 | CCEXTRA= 24 | LDEXTRA= 25 | -------------------------------------------------------------------------------- /volume1/Sources/18ListTitle/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | enum 8 | { 9 | M_RESET_WINDOW = 'rswn', 10 | M_SET_TITLE = 'sttl' 11 | }; 12 | 13 | MainWindow::MainWindow(void) 14 | : BWindow(BRect(100,100,500,400),"The Weird World of Sports",B_TITLED_WINDOW, 15 | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE) 16 | { 17 | // Here we will make a BView that covers the white area so that we can set the 18 | // "background color" 19 | BRect r(Bounds()); 20 | BView *top = new BView(r,"topview",B_FOLLOW_ALL,B_WILL_DRAW); 21 | AddChild(top); 22 | 23 | // ui_color() returns a system color, such as the window tab color, menu text color, 24 | // and so forth. 25 | top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 26 | 27 | // Create a button and place it at the bottom right corner of the window. The empty BRect 28 | // that we use for the BButton's frame is because we're going to have it resize itself and 29 | // then move it to the corner based on the actual size of the button 30 | BButton *reset = new BButton(BRect(),"resetbutton","Reset", new BMessage(M_RESET_WINDOW), 31 | B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); 32 | top->AddChild(reset); 33 | reset->ResizeToPreferred(); 34 | 35 | // Bottom right corner of the window with 10 pixels of padding between the button and the 36 | // window edge. 10 pixels is kind of a de facto standard for control padding. 37 | reset->MoveTo(Bounds().right - reset->Bounds().Width() - 10.0, 38 | Bounds().bottom - reset->Bounds().Height() - 10.0); 39 | 40 | r = Bounds(); 41 | r.InsetBy(10.0,10.0); 42 | 43 | // When working with BScrollViews, you must compensate for the width/height of the scrollbars. 44 | // B_V_SCROLL_BAR_WIDTH is a defined constant for the width of the vertical scroll bar. 45 | r.right -= B_V_SCROLL_BAR_WIDTH; 46 | 47 | // Frame() works like Bounds() except that it returns the size and location of the control 48 | // in the coordinate space of the parent view. This will make fListView's bottom stop 10 49 | // pixels above the button. 50 | r.bottom = reset->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT; 51 | 52 | // Most of these parameters are exactly the same as for BView except that we can also 53 | // specify whether the user is able to select just 1 item in the list or multiple items by 54 | // clicking on items while holding a modifier key on the keyboard. 55 | fListView = new BListView(r,"sportlist",B_SINGLE_SELECTION_LIST,B_FOLLOW_ALL); 56 | 57 | // We didn't call AddChild on fListView because our BScrollView will do that for us. When 58 | // created, it creates scrollbars and targets the specified view for any scrolling they do. 59 | // When the BScrollView is attached to the window, it calls AddChild on fListView for us. 60 | 61 | // If we call AddChild on fListView before we create this scrollview, our program will drop 62 | // to the debugger when we call AddChild on the BScrollView -- a BView can have only one parent. 63 | BScrollView *scrollView = new BScrollView("scrollview",fListView, B_FOLLOW_ALL, 0,true,true); 64 | top->AddChild(scrollView); 65 | 66 | // A BListView's selection message is sent to the window any time that the list's selection 67 | // changes. 68 | fListView->SetSelectionMessage(new BMessage(M_SET_TITLE)); 69 | 70 | fListView->AddItem(new BStringItem("Toe Wrestling")); 71 | fListView->AddItem(new BStringItem("Electric Toilet Racing")); 72 | fListView->AddItem(new BStringItem("Bog Snorkeling")); 73 | fListView->AddItem(new BStringItem("Chess Boxing")); 74 | fListView->AddItem(new BStringItem("Cheese Rolling")); 75 | fListView->AddItem(new BStringItem("Unicycle Polo")); 76 | } 77 | 78 | 79 | void 80 | MainWindow::MessageReceived(BMessage *msg) 81 | { 82 | switch (msg->what) 83 | { 84 | case M_RESET_WINDOW: 85 | { 86 | fListView->DeselectAll(); 87 | break; 88 | } 89 | case M_SET_TITLE: 90 | { 91 | int32 selection = fListView->CurrentSelection(); 92 | 93 | if (selection < 0) 94 | { 95 | // This code is here because when we press the Reset button, the selection 96 | // changes and an M_SET_TITLE message is sent, but because nothing is 97 | // selected, CurrentSelection() returns -1. 98 | SetTitle("The Weird World of Sports"); 99 | break; 100 | } 101 | 102 | BStringItem *item = dynamic_cast(fListView->ItemAt(selection)); 103 | if (item) 104 | SetTitle(item->Text()); 105 | break; 106 | } 107 | default: 108 | { 109 | BWindow::MessageReceived(msg); 110 | break; 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /volume1/Sources/18ListTitle/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | class MainWindow : public BWindow 8 | { 9 | public: 10 | MainWindow(void); 11 | void MessageReceived(BMessage *msg); 12 | 13 | private: 14 | BListView *fListView; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-Emo") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/Emo.pld: -------------------------------------------------------------------------------- 1 | NAME=Emo 2 | TARGETNAME=Emo 3 | PLATFORM=Zeta 4 | GROUP=Source Files 5 | EXPANDGROUP=yes 6 | SOURCEFILE=App.cpp 7 | DEPENDENCY=/BeData/projects/Emo/MainWindow.h 8 | SOURCEFILE=MainWindow.cpp 9 | DEPENDENCY=/BeData/projects/Emo/MainWindow.h 10 | SOURCEFILE=PictureView.cpp 11 | DEPENDENCY=/BeData/projects/Emo/PictureView.h 12 | SOURCEFILE=Resources.rsrc 13 | LOCALINCLUDE=/boot/home/projects/Emo/. 14 | SYSTEMINCLUDE=/boot/develop/headers/be 15 | SYSTEMINCLUDE=/boot/develop/headers/cpp 16 | SYSTEMINCLUDE=/boot/develop/headers/posix 17 | SYSTEMINCLUDE=/boot/home/config/include 18 | LIBRARY=/boot/develop/lib/x86/libroot.so 19 | LIBRARY=/boot/develop/lib/x86/libbe.so 20 | LIBRARY=/boot/develop/lib/x86/libtranslation.so 21 | RUNARGS= 22 | CCDEBUG=no 23 | CCPROFILE=no 24 | CCOPSIZE=no 25 | CCOPLEVEL=0 26 | CCTARGETTYPE=0 27 | CCEXTRA= 28 | LDEXTRA= 29 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "PictureView.h" 7 | 8 | MainWindow::MainWindow(void) 9 | : BWindow(BRect(300,300,450,450),"Emo",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 10 | { 11 | // Once again, we will make a background view to make things look nice 12 | BView *top = new BView(Bounds(),"top",B_FOLLOW_ALL,B_WILL_DRAW); 13 | top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 14 | AddChild(top); 15 | 16 | // This is our own BView subclass which draws one of several pictures 17 | PictureView *picview = new PictureView(); 18 | 19 | // Note that we have the background view add our picture view as a child. 20 | // Unpredictable drawing results will result when views overlap each other. You 21 | // can also run into problems where a view which is drawn on the screen doesn't 22 | // receive mouse events and other bizarre situations. 23 | top->AddChild(picview); 24 | 25 | // Move our picture view to the center of the window. This code right here is 26 | // very common, so get used to seeing and/or using it. 27 | picview->MoveTo((Bounds().Width() - picview->Bounds().Width()) / 2.0, 28 | (Bounds().Height() - picview->Bounds().Height()) / 2.0); 29 | } 30 | 31 | 32 | // QuitRequested() is a BWindow hook function which is called when the window is asked 33 | // to close. When it returns true, the window is given "permission" to quit and it does. 34 | // If QuitRequested() returns false, the window just keeps on running as if nothing 35 | // happened. Implementing this hook to send a quit message to the global application 36 | // instance is the old way of making an app quit when the main window is closed. It is 37 | // included here because legacy apps do it this way instead of using the 38 | // B_QUIT_ON_WINDOW_CLOSE flag in the constructor. This function also has its uses for 39 | // situations where you need to ask the user "Would you like to save your changes?" and 40 | // giving the user a chance to cancel the window closing altogether. 41 | bool 42 | MainWindow::QuitRequested(void) 43 | { 44 | be_app->PostMessage(B_QUIT_REQUESTED); 45 | return true; 46 | } 47 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | class MainWindow : public BWindow 7 | { 8 | public: 9 | MainWindow(void); 10 | bool QuitRequested(void); 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/PictureView.cpp: -------------------------------------------------------------------------------- 1 | #include "PictureView.h" 2 | #include 3 | #include 4 | 5 | // This class is our own special control. It loads five images from the application 6 | // resources and places them in an array. Once loaded, it resizes itself to exactly 7 | // fit the first bitmap. Since they are all the same size, this assumption is OK. 8 | PictureView::PictureView(void) 9 | : BView(BRect(0,0,100,100), "picview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW), 10 | fBitmapIndex(0) 11 | { 12 | // Load up all our pictures using a loop. There are 5 different versions of 13 | // BTranslationUtils::GetBitmap. This is one of two which load images from program 14 | // resources. 15 | for (int8 i = 1; i <= 5; i++) 16 | { 17 | BBitmap *smiley = BTranslationUtils::GetBitmap(B_PNG_FORMAT,i); 18 | fBitmaps[i - 1] = (smiley && smiley->IsValid()) ? smiley : NULL; 19 | } 20 | 21 | if (fBitmaps[0] && fBitmaps[0]->IsValid()) 22 | ResizeTo(fBitmaps[0]->Bounds().Width(),fBitmaps[0]->Bounds().Height()); 23 | } 24 | 25 | 26 | PictureView::~PictureView(void) 27 | { 28 | } 29 | 30 | 31 | // The BView's Draw() function is called whenever it is asked to draw itself 32 | // on the screen. This is one of the few places where its drawing commands can be 33 | // called. 34 | void 35 | PictureView::Draw(BRect rect) 36 | { 37 | // Alpha transparency is ignored in the default drawing mode for performance reasons, 38 | // so we will set the drawing mode to utilizes transparency information. 39 | SetDrawingMode(B_OP_ALPHA); 40 | 41 | // Set the foreground color of the BView to white 42 | SetHighColor(255,255,255); 43 | 44 | // Fill the BView's area with white. Like with most BView drawing commands, the last 45 | // argument is the color to use which defaults to the high color. Other color choices are 46 | // B_SOLID_LOW, which uses the background color, and B_MIXED_COLORS, which mixes the high 47 | // and low colors. 48 | FillRect(Bounds()); 49 | 50 | // Draw the current bitmap on the screen 51 | if (fBitmaps[fBitmapIndex]) 52 | DrawBitmap(fBitmaps[fBitmapIndex]); 53 | 54 | // Set the foreground color to black 55 | SetHighColor(0,0,0); 56 | 57 | // Draw a black border around the view 58 | StrokeRect(Bounds()); 59 | } 60 | 61 | 62 | // Mouse handling is kinda funny. BView has three hook functions for it: MouseDown(), which is 63 | // called whenever the user presses down a mouse button while the pointer is over the view, MouseUp, 64 | // which is called whenever the user releases a mouse button while the pointer is over the view, 65 | // and MouseMoved(), which is called whenever the mouse changes position while over the view. This 66 | // gives you, the developer, a great deal of control over how your view reacts to any kind of mouse 67 | // event. 68 | void 69 | PictureView::MouseUp(BPoint pt) 70 | { 71 | // Go to the next image in the array or loop around to the beginning if at the end. 72 | if (fBitmapIndex == sizeof(*fBitmaps)) 73 | fBitmapIndex = 0; 74 | else 75 | fBitmapIndex++; 76 | 77 | // Force a redraw of the entire view because we've changed pictures 78 | Invalidate(); 79 | } 80 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/PictureView.h: -------------------------------------------------------------------------------- 1 | #ifndef PICTUREVIEW_H 2 | #define PICTUREVIEW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class PictureView : public BView 10 | { 11 | public: 12 | PictureView(void); 13 | ~PictureView(void); 14 | 15 | void Draw(BRect rect); 16 | void MouseUp(BPoint pt); 17 | 18 | private: 19 | BBitmap *fBitmaps[5]; 20 | int8 fBitmapIndex; 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /volume1/Sources/19Emo/Resources.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/19Emo/Resources.rsrc -------------------------------------------------------------------------------- /volume1/Sources/20ListDir/App.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | // It's better to use constant global integers instead of #defines because constants 8 | // provide strong typing and don't lead to weird errors like #defines can. 9 | const uint16 BYTES_PER_KB = 1024; 10 | const uint32 BYTES_PER_MB = 1048576; 11 | const uint64 BYTES_PER_GB = 1099511627776ULL; 12 | 13 | int ListDirectory(const entry_ref &dirRef); 14 | BString MakeSizeString(const uint64 &size); 15 | 16 | 17 | int 18 | main(int argc, char **argv) 19 | { 20 | // We want to require one argument in addition to the program name when invoked 21 | // from the command line. 22 | if (argc != 2) 23 | { 24 | printf("Usage: listdir \n"); 25 | return 0; 26 | } 27 | 28 | // Here we'll do some sanity checks to make sure that the path we were given 29 | // actually exists and it's not a file. 30 | 31 | BEntry entry(argv[1]); 32 | if (!entry.Exists()) 33 | { 34 | printf("%s does not exist\n",argv[1]); 35 | return 1; 36 | } 37 | 38 | if (!entry.IsDirectory()) 39 | { 40 | printf("%s is not a directory\n",argv[1]); 41 | return 1; 42 | } 43 | 44 | // An entry_ref is a typedef'ed structure which points to a file, directory, or 45 | // symlink on disk. The entry must actually exist, but unlike a BFile or BEntry, it 46 | // doesn't use up a file handle. 47 | entry_ref ref; 48 | entry.GetRef(&ref); 49 | return ListDirectory(ref); 50 | } 51 | 52 | 53 | int 54 | ListDirectory(const entry_ref &dirRef) 55 | { 56 | // This function does all the work of the program 57 | 58 | BDirectory dir(&dirRef); 59 | if (dir.InitCheck() != B_OK) 60 | { 61 | printf("Couldn't read directory %s\n",dirRef.name); 62 | return 1; 63 | } 64 | 65 | // First thing we'll do is quickly scan the directory to find the length of the 66 | // longest entry name. This makes it possible to left justify the file sizes 67 | int32 entryCount = 0; 68 | uint32 maxChars = 0; 69 | entry_ref ref; 70 | 71 | // Calling Rewind() moves the BDirectory's index to the beginning of the list. 72 | dir.Rewind(); 73 | 74 | // GetNextRef() will return B_ERROR when the BDirectory has gotten to the end of 75 | // its list of entries. 76 | while (dir.GetNextRef(&ref) == B_OK) 77 | { 78 | if (ref.name) 79 | maxChars = MAX(maxChars,strlen(ref.name)); 80 | } 81 | maxChars++; 82 | char padding[maxChars]; 83 | 84 | BEntry entry; 85 | dir.Rewind(); 86 | 87 | // Here we'll call GetNextEntry() instead of GetNextRef() because a BEntry will 88 | // enable us to get certain information about each entry, such as the entry's size. 89 | // Also, because it inherits from BStatable, we can differentiate between 90 | // directories and files with just one function call. 91 | while (dir.GetNextEntry(&entry) == B_OK) 92 | { 93 | char name[B_FILE_NAME_LENGTH]; 94 | entry.GetName(name); 95 | 96 | BString formatString; 97 | formatString << "%s"; 98 | 99 | unsigned int length = strlen(name); 100 | if (length < maxChars) 101 | { 102 | uint32 padLength = maxChars - length; 103 | memset(padding, ' ', padLength); 104 | padding[padLength - 1] = '\0'; 105 | formatString << padding; 106 | } 107 | 108 | if (entry.IsDirectory()) 109 | { 110 | // We'll display the "size" of a directory by listing how many 111 | // entries it contains 112 | BDirectory subdir(&entry); 113 | formatString << "\t" << subdir.CountEntries() << " items"; 114 | } 115 | else 116 | { 117 | off_t fileSize; 118 | entry.GetSize(&fileSize); 119 | formatString << "\t" << MakeSizeString(fileSize); 120 | } 121 | formatString << "\n"; 122 | printf(formatString.String(),name); 123 | entryCount++; 124 | } 125 | printf("%ld entries\n",entryCount); 126 | return 0; 127 | } 128 | 129 | 130 | BString 131 | MakeSizeString(const uint64 &size) 132 | { 133 | // This function just makes converts the raw byte counts provided by 134 | // BEntry's GetSize() method into something more people-friendly. 135 | BString sizeString; 136 | if (size < BYTES_PER_KB) 137 | sizeString << size << " bytes"; 138 | else if (size < BYTES_PER_MB) 139 | sizeString << (float(size) / float(BYTES_PER_KB)) << " KB"; 140 | else if (size < BYTES_PER_GB) 141 | sizeString << (float(size) / float(BYTES_PER_MB)) << " MB"; 142 | else 143 | sizeString << (float(size) / float(BYTES_PER_GB)) << " GB"; 144 | return sizeString; 145 | } 146 | 147 | -------------------------------------------------------------------------------- /volume1/Sources/20ListDir/ListDir.pld: -------------------------------------------------------------------------------- 1 | NAME=ListDir 2 | TARGETNAME=listdir 3 | PLATFORM=Zeta 4 | GROUP=Source Files 5 | EXPANDGROUP=yes 6 | SOURCEFILE=App.cpp 7 | DEPENDENCY=/BeData/projects/Programming Lessons/ListDir/App.h 8 | LOCALINCLUDE=/boot/home/projects/ListDir/. 9 | SYSTEMINCLUDE=/boot/develop/headers/be 10 | SYSTEMINCLUDE=/boot/develop/headers/cpp 11 | SYSTEMINCLUDE=/boot/develop/headers/posix 12 | SYSTEMINCLUDE=/boot/home/config/include 13 | LIBRARY=/boot/develop/lib/x86/libroot.so 14 | LIBRARY=/boot/develop/lib/x86/libbe.so 15 | RUNARGS= 16 | CCDEBUG=yes 17 | CCPROFILE=no 18 | CCOPSIZE=no 19 | CCOPLEVEL=0 20 | CCTARGETTYPE=0 21 | CCEXTRA= 22 | LDEXTRA= 23 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "FortuneFunctions.h" 9 | #include "MainWindow.h" 10 | 11 | App::App(void) 12 | : BApplication("application/x-vnd.test-HaikuFortune") 13 | { 14 | BPath path; 15 | 16 | // We have to use an #ifdef here because the fortune files under R5 17 | // and Zeta are in the system/etc/ directory, but in Haiku they're 18 | // kept in the system/data directory. 19 | #ifdef __HAIKU__ 20 | find_directory(B_SYSTEM_DATA_DIRECTORY,&path); 21 | #else 22 | find_directory(B_BEOS_ETC_DIRECTORY,&path); 23 | #endif 24 | 25 | path.Append("fortunes"); 26 | gFortunePath = path.Path(); 27 | 28 | // If we want the rand() function to actually be pretty close to random 29 | // we will need to seed the random number generator with the time. If we 30 | // don't, we will get the same "random" numbers each time the program is 31 | // run. 32 | srand(system_time()); 33 | 34 | MainWindow *win = new MainWindow(); 35 | win->Show(); 36 | } 37 | 38 | 39 | int 40 | main(void) 41 | { 42 | srand(system_time()); 43 | 44 | App *app = new App(); 45 | app->Run(); 46 | delete app; 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/FortuneFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "FortuneFunctions.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | // Initialize the global path to a hardcoded value just in case. 14 | // This happens to be different under Haiku than under previous versions 15 | // of BeOS 16 | BString gFortunePath = "/boot/system/data/fortunes"; 17 | 18 | 19 | FortuneAccess::FortuneAccess(void) 20 | { 21 | } 22 | 23 | 24 | FortuneAccess::FortuneAccess(const char *folder) 25 | { 26 | SetFolder(folder); 27 | } 28 | 29 | 30 | FortuneAccess::~FortuneAccess(void) 31 | { 32 | // We have to call MakeEmpty because the BList class 33 | // does not delete any items that it contains 34 | MakeEmpty(); 35 | } 36 | 37 | 38 | status_t 39 | FortuneAccess::SetFolder(const char *folder) 40 | { 41 | if (!folder) 42 | return B_BAD_VALUE; 43 | 44 | fPath = folder; 45 | ScanFolder(); 46 | 47 | return B_OK; 48 | } 49 | 50 | 51 | status_t 52 | FortuneAccess::GetFortune(BString &target) 53 | { 54 | // Here's the meat of this class: 55 | if (fPath.CountChars() == 0) 56 | return B_NO_INIT; 57 | 58 | if (fRefList.CountItems() < 1) 59 | return B_ERROR; 60 | 61 | int32 index = int32(float(rand()) / RAND_MAX * fRefList.CountItems()); 62 | 63 | entry_ref *ref = static_cast(fRefList.ItemAt(index)); 64 | 65 | BFile file(ref,B_READ_ONLY); 66 | if (file.InitCheck() != B_OK) 67 | return file.InitCheck(); 68 | 69 | fLastFile = ref->name; 70 | 71 | off_t size; 72 | file.GetSize(&size); 73 | 74 | if (size < 1) 75 | return B_ERROR; 76 | 77 | BString data; 78 | char *buffer = data.LockBuffer(size + 10); 79 | file.Read(buffer, size); 80 | data.UnlockBuffer(); 81 | buffer = NULL; 82 | 83 | // We can't depend on a .dat file, so calculate the number of entries manually 84 | int32 entrycount = 0; 85 | int32 entrystart = 0; 86 | do 87 | { 88 | entrystart = data.FindFirst("%\n", entrystart + 1); 89 | entrycount++; 90 | } while (entrystart > 0); 91 | 92 | int32 entry = int32(float(rand()) / RAND_MAX * (entrycount - 1)); 93 | 94 | entrystart = 0; 95 | for (int32 i = 0; i < entry; i++) 96 | entrystart = data.FindFirst("%\n",entrystart + 1); 97 | 98 | BString entrydata; 99 | entrydata = data.String() + entrystart + 2; 100 | int32 entrylength = entrydata.FindFirst("%\n"); 101 | if (entrylength > 0) 102 | entrydata.Truncate(entrylength); 103 | 104 | target = entrydata; 105 | return B_OK; 106 | } 107 | 108 | 109 | void 110 | FortuneAccess::ScanFolder(void) 111 | { 112 | // Scan the directory that the object was set to and create a list of all 113 | // of the names of the files in the directory. 114 | BDirectory dir(fPath.String()); 115 | if (dir.InitCheck() != B_OK) 116 | return; 117 | 118 | MakeEmpty(); 119 | entry_ref ref; 120 | while (dir.GetNextRef(&ref) == B_OK) 121 | { 122 | BEntry entry(&ref); 123 | if (entry.IsFile()) 124 | fRefList.AddItem(new entry_ref(ref)); 125 | } 126 | } 127 | 128 | 129 | void 130 | FortuneAccess::MakeEmpty(void) 131 | { 132 | // This method is needed because BList doesn't free the memory of the items 133 | // that it holds. 134 | for (int32 i = 0; i < fRefList.CountItems(); i++) 135 | { 136 | entry_ref *ref = (entry_ref*)fRefList.ItemAt(i); 137 | delete ref; 138 | } 139 | fRefList.MakeEmpty(); 140 | } 141 | 142 | 143 | int32 144 | FortuneAccess::CountFiles(void) const 145 | { 146 | return fRefList.CountItems(); 147 | } 148 | 149 | 150 | status_t 151 | FortuneAccess::LastFilename(BString &target) 152 | { 153 | // This function exists so that outside code can find out the name of the file 154 | // the most recent fortune came from. 155 | if (fPath.CountChars() == 0) 156 | return B_NO_INIT; 157 | 158 | target = fLastFile; 159 | 160 | return B_OK; 161 | } 162 | 163 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/FortuneFunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef FORTUNEFUNCTIONS_H 2 | #define FORTUNEFUNCTIONS_H 3 | 4 | #include 5 | #include 6 | 7 | extern BString gFortunePath; 8 | 9 | class FortuneAccess 10 | { 11 | public: 12 | FortuneAccess(void); 13 | FortuneAccess(const char *folder); 14 | ~FortuneAccess(void); 15 | 16 | status_t SetFolder(const char *folder); 17 | status_t GetFortune(BString &target); 18 | int32 CountFiles(void) const; 19 | status_t LastFilename(BString &target); 20 | 21 | private: 22 | void ScanFolder(void); 23 | void MakeEmpty(void); 24 | 25 | BString fPath, 26 | fLastFile; 27 | BList fRefList; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/HaikuFortune.pld: -------------------------------------------------------------------------------- 1 | NAME=HaikuFortune 2 | TARGETNAME=HaikuFortune 3 | PLATFORM=Zeta 4 | GROUP=Fortuna 5 | EXPANDGROUP=yes 6 | SOURCEFILE=App.cpp 7 | DEPENDENCY=/BeData/projects/Programming Lessons/HaikuFortune/App.h|/BeData/projects/Programming Lessons/HaikuFortune/FortuneFunctions.h|/BeData/projects/Programming Lessons/HaikuFortune/MainWindow.h 8 | SOURCEFILE=FortuneFunctions.cpp 9 | DEPENDENCY=/boot/home/Desktop/Fortuna/FortuneFunctions.h 10 | SOURCEFILE=MainWindow.cpp 11 | DEPENDENCY=/BeData/projects/Programming Lessons/HaikuFortune/MainWindow.cpp|/BeData/projects/Programming Lessons/HaikuFortune/MainWindow.h|/BeData/projects/Programming Lessons/HaikuFortune/FortuneFunctions.h 12 | SOURCEFILE=Resources.rsrc 13 | LOCALINCLUDE=/boot/home/projects/Fortuna/. 14 | SYSTEMINCLUDE=/boot/develop/headers/be 15 | SYSTEMINCLUDE=/boot/develop/headers/cpp 16 | SYSTEMINCLUDE=/boot/develop/headers/posix 17 | SYSTEMINCLUDE=/boot/home/config/include 18 | LIBRARY=/boot/develop/lib/x86/libroot.so 19 | LIBRARY=/boot/develop/lib/x86/libbe.so 20 | RUNARGS= 21 | CCDEBUG=no 22 | CCPROFILE=no 23 | CCOPSIZE=no 24 | CCOPLEVEL=0 25 | CCTARGETTYPE=0 26 | CCEXTRA= 27 | LDEXTRA= 28 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/HaikuFortune.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/22HaikuFortune/HaikuFortune.rsrc -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/HaikuFortune16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/22HaikuFortune/HaikuFortune16.png -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/HaikuFortune32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/22HaikuFortune/HaikuFortune32.png -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | enum 11 | { 12 | M_GET_ANOTHER_FORTUNE = 'gafn', 13 | M_ABOUT_REQUESTED = 'abrq' 14 | }; 15 | 16 | 17 | MainWindow::MainWindow(void) 18 | : BWindow(BRect(0,0,300,300), "HaikuFortune", B_DOCUMENT_WINDOW, 19 | B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE), 20 | fFortune(gFortunePath.String()) 21 | { 22 | // Create all of the controls for our window. 23 | BView *back = new BView(Bounds(), "background", B_FOLLOW_ALL, B_WILL_DRAW); 24 | back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 25 | AddChild(back); 26 | 27 | BButton *close = new BButton(BRect(0,0,1,1), "closebutton", "Close", 28 | new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); 29 | close->ResizeToPreferred(); 30 | close->MoveTo(Bounds().right - 15 - close->Frame().Width(), 31 | Bounds().bottom - 15 - close->Frame().Height()); 32 | back->AddChild(close); 33 | close->MakeDefault(true); 34 | 35 | BButton *next = new BButton(BRect(0,0,1,1), "nextbutton", "Get Another", 36 | new BMessage(M_GET_ANOTHER_FORTUNE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); 37 | next->ResizeToPreferred(); 38 | next->MoveTo(close->Frame().left - 15 - next->Frame().Width(), 39 | Bounds().bottom - 15 - next->Frame().Height()); 40 | back->AddChild(next); 41 | 42 | BButton *about = new BButton(BRect(0,0,1,1), "aboutbutton", "About…", 43 | new BMessage(M_ABOUT_REQUESTED), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); 44 | about->ResizeToPreferred(); 45 | about->MoveTo(next->Frame().left - 15 - about->Frame().Width(), 46 | Bounds().bottom - 15 - about->Frame().Height()); 47 | back->AddChild(about); 48 | 49 | 50 | BRect r(15,15,Bounds().right - B_V_SCROLL_BAR_WIDTH - 15, next->Frame().top - 15); 51 | fTextView = new BTextView(r, "textview", r.OffsetToCopy(0,0).InsetByCopy(10,10), B_FOLLOW_ALL, 52 | B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS); 53 | fTextView->MakeEditable(false); 54 | 55 | // BScrollViews are a little weird. You can't create one without having created its target. 56 | // It also automatically calls AddChild() to attach its target to itself, so all that is 57 | // necessary is to instantiate it and attach it to the window. It's not even necessary (or 58 | // possible) to specify the size of the BScrollView because it calculates its size based 59 | // on that of its target. 60 | BScrollView *sv = new BScrollView("scrollview", fTextView, B_FOLLOW_ALL, 0, false, true); 61 | back->AddChild(sv); 62 | 63 | BString fortune; 64 | status_t status = fFortune.GetFortune(fortune); 65 | if (status == B_OK) 66 | { 67 | BString title; 68 | title.Prepend("Fortune: "); 69 | SetTitle(title.String()); 70 | 71 | fTextView->SetText(fortune.String()); 72 | } 73 | else 74 | { 75 | fTextView->SetText("HaikuFortune had a problem getting a fortune.\n\n" 76 | "Please make sure that you have installed fortune files to " 77 | "the folder "); 78 | fTextView->Insert(gFortunePath.String()); 79 | } 80 | 81 | // This line is for working around a problem in Zeta. BButton::MakeDefault doesn't 82 | // do anything except change the focus. The idea is to be able to press Enter to close 83 | // HaikuFortune and the space bar to get another fortune. Zeta doesn't let us do this, so 84 | // we'll leave focus on the Close button. 85 | if (B_BEOS_VERSION <= B_BEOS_VERSION_5) 86 | next->MakeFocus(true); 87 | 88 | // Calculate a good width for the window and center it 89 | SetSizeLimits(45 + close->Bounds().Width() + next->Bounds().Width(), 30000, 200, 30000) ; 90 | r = BScreen().Frame(); 91 | MoveTo((r.Width()-Bounds().Width()) / 2.0, r.Height() / 4.0); 92 | } 93 | 94 | 95 | void 96 | MainWindow::MessageReceived(BMessage *msg) 97 | { 98 | switch (msg->what) 99 | { 100 | case M_GET_ANOTHER_FORTUNE: 101 | { 102 | BString fortune; 103 | status_t status = fFortune.GetFortune(fortune); 104 | if (status == B_OK) 105 | { 106 | BString title; 107 | fFortune.LastFilename(title); 108 | title.Prepend("Fortune: "); 109 | SetTitle(title.String()); 110 | 111 | fTextView->SetText(fortune.String()); 112 | } 113 | else 114 | { 115 | fTextView->SetText("HaikuFortune had a problem getting a fortune.\n\n" 116 | "Please make sure that you have installed fortune files to " 117 | "the folder "); 118 | fTextView->Insert(gFortunePath.String()); 119 | } 120 | break; 121 | } 122 | case M_ABOUT_REQUESTED: 123 | { 124 | // Using a BAlert for the About window is a common occurrence. They take 125 | // care of all of the layout, so all that needs done is write the text that 126 | // goes in the alert. 127 | BAlert *alert = new BAlert("HaikuFortune", 128 | "A graphical fortune program for Haiku.\n\n", 129 | "OK"); 130 | alert->Go(); 131 | break; 132 | } 133 | default: 134 | { 135 | BWindow::MessageReceived(msg); 136 | break; 137 | } 138 | } 139 | } 140 | 141 | 142 | void 143 | MainWindow::FrameResized(float w, float h) 144 | { 145 | // The BWindow::FrameResized() method is called whenever the window is resized. 146 | // In this case, we change the size of the text rectangle in the text view used 147 | // for the fortune. We have to do this because it won't do it itself. Lazy. 148 | BRect textrect = fTextView->TextRect(); 149 | 150 | textrect.right = textrect.left + (w - B_V_SCROLL_BAR_WIDTH - 40); 151 | fTextView->SetTextRect(textrect); 152 | } 153 | 154 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include "FortuneFunctions.h" 7 | 8 | class MainWindow : public BWindow 9 | { 10 | public: 11 | MainWindow(void); 12 | void MessageReceived(BMessage *msg); 13 | void FrameResized(float w, float h); 14 | 15 | private: 16 | BTextView *fTextView; 17 | FortuneAccess fFortune; 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /volume1/Sources/22HaikuFortune/Resources.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/22HaikuFortune/Resources.rsrc -------------------------------------------------------------------------------- /volume1/Sources/DropMe/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-DropMe") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume1/Sources/DropMe/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume1/Sources/DropMe/DropMe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/Sources/DropMe/DropMe -------------------------------------------------------------------------------- /volume1/Sources/DropMe/DropMe.pld: -------------------------------------------------------------------------------- 1 | NAME=DropMe 2 | TARGETNAME=DropMe 3 | GROUP=Source Files 4 | EXPANDGROUP=yes 5 | SOURCEFILE=App.cpp 6 | DEPENDENCY=/boot/home/projects/DropMe/App.cpp| /boot/home/projects/DropMe/App.h| /boot/home/projects/DropMe/MainWindow. 7 | SOURCEFILE=DropView.cpp 8 | DEPENDENCY=/boot/home/projects/DropMe/DropView.cpp| /boot/home/projects/DropMe/DropView. 9 | SOURCEFILE=MainWindow.cpp 10 | DEPENDENCY=/boot/home/projects/DropMe/MainWindow.cpp| /boot/home/projects/DropMe/MainWindow.h| /boot/home/projects/DropMe/DropView. 11 | LOCALINCLUDE=/boot/home/projects/DropMe/. 12 | SYSTEMINCLUDE=/boot/develop/headers/be 13 | SYSTEMINCLUDE=/boot/develop/headers/cpp 14 | SYSTEMINCLUDE=/boot/develop/headers/posix 15 | SYSTEMINCLUDE=/boot/home/config/include 16 | LIBRARY=/boot/develop/lib/x86/libroot.so 17 | LIBRARY=/boot/develop/lib/x86/libbe.so 18 | LIBRARY=/boot/system/lib/libsupc++.so 19 | RUNARGS= 20 | CCDEBUG=no 21 | CCPROFILE=no 22 | CCOPSIZE=no 23 | CCOPLEVEL=0 24 | CCTARGETTYPE=0 25 | CCEXTRA= 26 | LDEXTRA= 27 | -------------------------------------------------------------------------------- /volume1/Sources/DropMe/DropView.cpp: -------------------------------------------------------------------------------- 1 | #include "DropView.h" 2 | 3 | // This header is needed for the definition of the entry_ref structure 4 | #include 5 | 6 | // This is for the methods we need to work with BMessages in MessageReceived 7 | #include 8 | 9 | 10 | DropView::DropView(const BRect &frame) 11 | : BView(frame, "dropview", B_FOLLOW_ALL, B_WILL_DRAW) 12 | { 13 | SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 14 | 15 | // Once again, create a label, this time to display the file's name 16 | fLabel = new BStringView(BRect(10,10,11,11),"label","Drag a file here"); 17 | fLabel->ResizeToPreferred(); 18 | AddChild(fLabel); 19 | } 20 | 21 | 22 | void 23 | DropView::MessageReceived(BMessage *msg) 24 | { 25 | switch (msg->what) 26 | { 27 | case B_SIMPLE_DATA: 28 | { 29 | // This message is the constant give to us whenever something is dropped 30 | // on a view from Tracker. 31 | 32 | // An entry_ref is a lightweight structure that identifies a file on disk 33 | // A file dropped on our BView will generate a message with the identifier 34 | // B_SIMPLE_DATA and attached data. The attached data takes the form of a 35 | // series of entry_refs with the field name "refs" 36 | entry_ref ref; 37 | 38 | // If FindRef is successful, the information about the file dropped on the 39 | // view will be copied into ref. 40 | if (msg->FindRef("refs",&ref) == B_OK) 41 | { 42 | // Most of the information in an entry_ref isn't very useful, but the 43 | // name property contains the file's name or NULL if the entry_ref is 44 | // empty 45 | fLabel->SetText(ref.name); 46 | } 47 | break; 48 | } 49 | default: 50 | { 51 | BView::MessageReceived(msg); 52 | break; 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /volume1/Sources/DropMe/DropView.h: -------------------------------------------------------------------------------- 1 | #ifndef DROPVIEW_H 2 | #define DROPVIEW_H 3 | 4 | #include 5 | #include 6 | 7 | class DropView : public BView 8 | { 9 | public: 10 | DropView(const BRect &frame); 11 | void MessageReceived(BMessage *msg); 12 | 13 | private: 14 | BStringView *fLabel; 15 | }; 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /volume1/Sources/DropMe/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | 5 | #include "DropView.h" 6 | 7 | MainWindow::MainWindow(void) 8 | : BWindow(BRect(100,100,400,300),"DropMe",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | 9 | B_QUIT_ON_WINDOW_CLOSE) 10 | { 11 | DropView *view = new DropView(Bounds()); 12 | AddChild(view); 13 | } 14 | 15 | 16 | void 17 | MainWindow::MessageReceived(BMessage *msg) 18 | { 19 | switch (msg->what) 20 | { 21 | default: 22 | { 23 | BWindow::MessageReceived(msg); 24 | break; 25 | } 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /volume1/Sources/DropMe/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | class MainWindow : public BWindow 7 | { 8 | public: 9 | MainWindow(void); 10 | void MessageReceived(BMessage *msg); 11 | 12 | private: 13 | }; 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /volume1/chapters/conclusions.Md: -------------------------------------------------------------------------------- 1 | # Where to Go from Here 2 | 3 | We have covered an enormous amount of information since Lesson 1. Amazingly, there is still a lot of ground to go if you would like to go beyond being a beginner. The best way to improve is to write code and keep learning as you go. What you know now will give you the ability to write a many different kinds of programs for Haiku and will also give you the tools to learn the rest of the Haiku API and other aspects of programming in C++. Here are some topics that you are encouraged to explore: 4 | 5 | ## C++ 6 | 7 | - Exceptions 8 | - Templates and the Standard Template Library 9 | - Multiple Inheritance 10 | 11 | ## Usability 12 | 13 | - *The Design of Everyday Things*, Donald Norman 14 | - *The Humane Interface*, Jef Raskin 15 | 16 | ## Good Programming 17 | 18 | - *Design Patterns: Elements of Reusable Object-Oriented Software*, Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides 19 | 20 | ## Programming for BeOS / Haiku 21 | 22 | - *Programming the Be Operating System*, Dan Parks Sydow. This is out-of-print but is available from O'Reilly's website as a free PDF. 23 | - The BeOS sample code projects and accompanying articles 24 | - *The Be Book*. This is the authoritative manual on the BeOS / Haiku API. 25 | -------------------------------------------------------------------------------- /volume1/chapters/disclaimer.Md: -------------------------------------------------------------------------------- 1 | # Disclaimer {.unnumbered} 2 | 3 | **Original title: Learning to Program with Haiku** 4 | 5 | *Copyright © 2010 by Jon Yoder* 6 | 7 | ### Notice of liability {.unnumbered} 8 | 9 | Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an "as is" basis. The author and Lulu.com shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. 10 | 11 | ### Trademarks {.unnumbered} 12 | 13 | Haiku and the Haiku logo are trademarks of Haiku, Inc. Be, BeOS, and the Be and BeOS logos are registered trademarks of Be Incorporated in the United States of America and other countries. All other products and company names mentioned in this book may be trademarks of their respective owners. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. 14 | 15 | ### License {.unnumbered} 16 | 17 | This work is licensed under the 18 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 19 | 20 | To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 21 | 22 | ![](images/cc-by-nc-sa.png) 23 | 24 | ISBN: 978-0-557-53969-7 25 | -------------------------------------------------------------------------------- /volume1/images/cc-by-nc-sa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/images/cc-by-nc-sa.png -------------------------------------------------------------------------------- /volume1/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/images/cover.png -------------------------------------------------------------------------------- /volume1/images/filetypes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/images/filetypes.png -------------------------------------------------------------------------------- /volume1/images/myfirstappshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/images/myfirstappshot.png -------------------------------------------------------------------------------- /volume1/images/paladin2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/images/paladin2.png -------------------------------------------------------------------------------- /volume1/images/quickres.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume1/images/quickres.png -------------------------------------------------------------------------------- /volume1/metadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | title: Programming with Haiku 3 | subtitle: The Basics 4 | author: Jon Yoder 5 | rights: Creative Commons Attribution 4.0 International 6 | language: en-US 7 | abstract: | 8 | This beginning programming guide takes the reader from know next to nothing 9 | about developing applications for the Haiku operating system to knowing the 10 | basics and having the skills to go beyond the fundamentals. It begins with 11 | a traditional "Hello, world! approach, moves through C programming, and 12 | expands into C++ and programming graphical applications for Haiku. 13 | Instead of attempting to be an exhaustive C/C++ programming book using Haiku, 14 | it focuses on application development using the C++ language. 15 | The Haiku operating system is a great platform for aspiring developers. 16 | Those who have struggled with learning application development under Linux, 17 | Microsoft Windows, or Macintosh will find writing programs under Haiku to be 18 | sensible and easy. The free Paladin integrated development environment for 19 | Haiku is used for examples in the book. 20 | pandoc-latex-environment: 21 | noteblock: [note] 22 | tipblock: [tip] 23 | warningblock: [warning] 24 | cautionblock: [caution] 25 | importantblock: [important] 26 | questionblock: [question] 27 | errorblock: [error] 28 | shellerrorblock: [shellerror] 29 | assignmentblock: [assignment] 30 | toughblock: [tough] 31 | bughuntblock: [bughunt] 32 | bugwarningblock: [bugwarning] 33 | ... 34 | -------------------------------------------------------------------------------- /volume2/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY = docbooks clean 2 | 3 | BUILD = build 4 | MAKEFILE = Makefile 5 | OUTPUT_FILENAME = Jon_Yoder_-_Programming_with_Haiku_Volume_2 6 | 7 | INCLUDE_DIR = ../include 8 | IMAGES_DIR = images 9 | IMAGES = $(IMAGES_DIR)/* 10 | COVER_IMAGE = $(IMAGES_DIR)/cover.png 11 | 12 | METADATA = metadata.yml 13 | TOC = --toc --toc-depth=2 -V toc-title='Table of contents' -V toc-own-page:true 14 | CSS_FILE = $(INCLUDE_DIR)/css/style.css 15 | CSS_ARG = --css=$(CSS_FILE) 16 | METADATA_ARG = --metadata-file=$(METADATA) 17 | MATH_FORMULAS = --webtex 18 | 19 | PDF_ENGINE=xelatex 20 | ARGS = $(MATH_FORMULAS) $(CSS_ARG) $(METADATA_ARG) 21 | 22 | MARKDOWN_FORMAT = markdown-pipe_tables+backtick_code_blocks+fancy_lists+table_captions+smart+fenced_divs 23 | 24 | CHAPTERS_DIR = ./chapters 25 | CHAPTERS := disclaimer.Md lesson01.Md 26 | 27 | CHAPTERS_TARGETS = $(addprefix $(CHAPTERS_DIR)/,$(CHAPTERS)) 28 | 29 | all: book 30 | 31 | book: epub html pdf mobi 32 | 33 | clean: 34 | rm -rf $(BUILD) 35 | 36 | markdown: $(BUILD)/markdown/$(OUTPUT_FILENAME).Md 37 | 38 | mobi: $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi 39 | 40 | epub: $(BUILD)/epub/$(OUTPUT_FILENAME).epub 41 | 42 | html: $(BUILD)/html/$(OUTPUT_FILENAME).html.tar.gz 43 | 44 | pdf: $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf 45 | 46 | png: pdf 47 | mkdir -p $(BUILD)/png 48 | pdftoppm -png -r 42 -aa yes $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf $(BUILD)/png/$(OUTPUT_FILENAME) 49 | 50 | $(BUILD)/markdown/$(OUTPUT_FILENAME).Md: $(CHAPTERS_TARGETS) 51 | mkdir -p $(BUILD)/markdown 52 | mdmerge $(CHAPTERS_TARGETS) -o $(BUILD)/markdown/$(OUTPUT_FILENAME).Md 53 | 54 | $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi: epub 55 | mkdir -p $(BUILD)/mobi 56 | ebook-convert $(BUILD)/epub/$(OUTPUT_FILENAME).epub $(BUILD)/mobi/$(OUTPUT_FILENAME).mobi 57 | 58 | $(BUILD)/epub/$(OUTPUT_FILENAME).epub: $(MAKEFILE) $(METADATA) $(CHAPTERS_TARGETS) $(CSS_FILE) $(IMAGES) \ 59 | $(COVER_IMAGE) 60 | mkdir -p $(BUILD)/epub 61 | pandoc $(ARGS) --epub-cover-image=$(COVER_IMAGE) -f $(MARKDOWN_FORMAT) -t epub -o $@ -s $(CHAPTERS_TARGETS) 62 | 63 | $(BUILD)/html/$(OUTPUT_FILENAME).html.tar.gz : $(MAKEFILE) $(METADATA) $(CHAPTERS_TARGETS) $(CSS_FILE) $(IMAGES) 64 | mkdir -p $(BUILD)/html_tmp 65 | mkdir -p $(BUILD)/html 66 | pandoc $(ARGS) --standalone --to=html5 -o $(BUILD)/html_tmp/$(OUTPUT_FILENAME).html $(CHAPTERS_TARGETS) 67 | cp -R $(IMAGES_DIR)/ $(BUILD)/html_tmp/$(IMAGES_DIR)/ 68 | tar -zcvf $(BUILD)/html/$(OUTPUT_FILENAME).html.tar.gz -C $(BUILD)/html_tmp . 69 | rm -r $(BUILD)/html_tmp 70 | 71 | $(BUILD)/pdf/$(OUTPUT_FILENAME).pdf: $(CHAPTERS_TARGETS) $(CSS_FILE) 72 | mkdir -p $(BUILD)/markdown 73 | mkdir -p $(BUILD)/pdf 74 | pandoc $(ARGS) \ 75 | $(TOC) \ 76 | --template=$(INCLUDE_DIR)/pandoc/eisvogel.latex \ 77 | --metadata=abstract:" " \ 78 | -V geometry:a4paper -V geometry:"left=2.54cm,right=2.54cm,top=1.91cm,bottom=1.91cm" \ 79 | -V titlepage:true -V titlepage-color:"FFFFFF" -V titlepage-rule-height:0 -V titlepage-rule-color:"d8dbdc" \ 80 | -V titlepage-background:$(COVER_IMAGE) \ 81 | -V title:"" -V subtitle:"" -V author:"" \ 82 | -V header-left:"Programming with Haiku" -V header-right:"Volume 2" \ 83 | -V footer-left:"Jon Yoder" \ 84 | -V links-as-notes:true \ 85 | -V lot:true \ 86 | -V footnotes-pretty:true \ 87 | --listing -V listings-disable-line-numbers:true \ 88 | -V book:true --top-level-division=chapter \ 89 | --pdf-engine=$(PDF_ENGINE) \ 90 | --include-in-header $(INCLUDE_DIR)/latex/preamble.tex \ 91 | --include-before-body $(INCLUDE_DIR)/latex/before_body.tex \ 92 | --include-after-body $(INCLUDE_DIR)/latex/after_body.tex \ 93 | --filter pandoc-latex-environment \ 94 | --number-offset=1 \ 95 | -f $(MARKDOWN_FORMAT) \ 96 | -s $(CHAPTERS_TARGETS) \ 97 | -o $@ 98 | 99 | %.xml : %.adoc 100 | asciidoctor -v -d book -b docbook -s $< -o $@ 101 | 102 | $(CHAPTERS_DIR)/%.Md : %.xml 103 | mkdir -p $(CHAPTERS_DIR) 104 | pandoc --highlight-style=pygments --wrap=none -f docbook -t $(MARKDOWN_FORMAT) --shift-heading-level-by=1 $< -o $@ 105 | 106 | -------------------------------------------------------------------------------- /volume2/Programming with Haiku -- GDB.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku -- GDB.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 1.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 1.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 10.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 10.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 11.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 11.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 12.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 12.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 13.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 13.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 14.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 14.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 15.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 15.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 16.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 16.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 17.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 17.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 18.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 18.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 19.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 19.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 2.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 2.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 20.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 20.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 21.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 21.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 22.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 22.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 23.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 23.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 24.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 24.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 25.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 25.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 26.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 26.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 27 (unfinished).odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 27 (unfinished).odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 28 (unfinished).odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 28 (unfinished).odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 3.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 3.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 4.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 4.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 5.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 5.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 6.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 6.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 7.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 7.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 8.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 8.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Lesson 9.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Lesson 9.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Unit 1 Review.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Unit 1 Review.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Unit 2 Review.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Unit 2 Review.odt -------------------------------------------------------------------------------- /volume2/Programming with Haiku Unit 3 Review.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Programming with Haiku Unit 3 Review.odt -------------------------------------------------------------------------------- /volume2/Sources/AutoTextControl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | AutoTextControl.cpp: A BTextControl which notifies on each keypress 3 | Written by DarkWyrm , Copyright 2007 4 | Released under the MIT license. 5 | */ 6 | #include "AutoTextControl.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | static property_info sProperties[] = { 14 | { "CharacterLimit", { B_GET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 }, 15 | "Returns the maximum number of characters that the AutoTextControl will allow.", 16 | 0, { B_INT32_TYPE } 17 | }, 18 | 19 | { "CharacterLimit", { B_SET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0}, 20 | "Sets the maximum number of characters that the AutoTextControl will allow.", 21 | 0, { B_INT32_TYPE } 22 | }, 23 | }; 24 | 25 | AutoTextControl::AutoTextControl(const BRect &frame, const char *name, const char *label, 26 | const char *text, BMessage *msg, uint32 resize, uint32 flags) 27 | : BTextControl(frame,name,label,text,msg,resize,flags), 28 | fFilter(NULL), 29 | fCharLimit(0) 30 | { 31 | SetFilter(new AutoTextControlFilter(this)); 32 | } 33 | 34 | 35 | AutoTextControl::~AutoTextControl(void) 36 | { 37 | if (Window()) 38 | Window()->RemoveCommonFilter(fFilter); 39 | 40 | delete fFilter; 41 | } 42 | 43 | 44 | AutoTextControl::AutoTextControl(BMessage *data) 45 | : BTextControl(data) 46 | { 47 | if (data->FindInt32("_charlimit",(int32*)&fCharLimit) != B_OK) 48 | fCharLimit = 0; 49 | } 50 | 51 | 52 | BArchivable * 53 | AutoTextControl::Instantiate(BMessage *data) 54 | { 55 | if (validate_instantiation(data, "AutoTextControl")) 56 | return new AutoTextControl(data); 57 | 58 | return NULL; 59 | } 60 | 61 | 62 | status_t 63 | AutoTextControl::Archive(BMessage *data, bool deep) const 64 | { 65 | status_t status = BTextControl::Archive(data,deep); 66 | 67 | if (status == B_OK) 68 | status = data->AddInt32("_charlimit",fCharLimit); 69 | 70 | if (status == B_OK) 71 | status = data->AddString("class","AutoTextControl"); 72 | 73 | return status; 74 | } 75 | 76 | 77 | status_t 78 | AutoTextControl::GetSupportedSuites(BMessage *msg) 79 | { 80 | msg->AddString("suites","suite/vnd.DW-autotextcontrol"); 81 | 82 | BPropertyInfo prop_info(sProperties); 83 | msg->AddFlat("messages",&prop_info); 84 | return BTextControl::GetSupportedSuites(msg); 85 | } 86 | 87 | 88 | BHandler * 89 | AutoTextControl::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, 90 | int32 form, const char *property) 91 | { 92 | return BControl::ResolveSpecifier(msg, index, specifier, form, property); 93 | } 94 | 95 | 96 | void 97 | AutoTextControl::AttachedToWindow(void) 98 | { 99 | BTextControl::AttachedToWindow(); 100 | if (fFilter) 101 | Window()->AddCommonFilter(fFilter); 102 | } 103 | 104 | 105 | void 106 | AutoTextControl::DetachedFromWindow(void) 107 | { 108 | if (fFilter) 109 | Window()->RemoveCommonFilter(fFilter); 110 | BTextControl::DetachedFromWindow(); 111 | } 112 | 113 | 114 | void 115 | AutoTextControl::SetCharacterLimit(const uint32 &limit) 116 | { 117 | fCharLimit = limit; 118 | } 119 | 120 | 121 | uint32 122 | AutoTextControl::GetCharacterLimit(const uint32 &limit) 123 | { 124 | return fCharLimit; 125 | } 126 | 127 | 128 | void 129 | AutoTextControl::AllowCharacters(const char *string) 130 | { 131 | uint32 i = 0; 132 | while (string[i]) 133 | TextView()->AllowChar(string[i++]); 134 | } 135 | 136 | 137 | void 138 | AutoTextControl::DisallowCharacters(const char *string) 139 | { 140 | uint32 i = 0; 141 | while (string[i]) 142 | TextView()->DisallowChar(string[i++]); 143 | } 144 | 145 | 146 | void 147 | AutoTextControl::SetFilter(AutoTextControlFilter *filter) 148 | { 149 | if (fFilter) { 150 | if (Window()) 151 | Window()->RemoveCommonFilter(fFilter); 152 | delete fFilter; 153 | } 154 | 155 | fFilter = filter; 156 | if (Window()) 157 | Window()->AddCommonFilter(fFilter); 158 | } 159 | 160 | AutoTextControlFilter::AutoTextControlFilter(AutoTextControl *box) 161 | : BMessageFilter(B_PROGRAMMED_DELIVERY, B_ANY_SOURCE,B_KEY_DOWN), 162 | fBox(box), 163 | fCurrentMessage(NULL) 164 | { 165 | } 166 | 167 | 168 | AutoTextControlFilter::~AutoTextControlFilter(void) 169 | { 170 | } 171 | 172 | 173 | filter_result 174 | AutoTextControlFilter::Filter(BMessage *msg, BHandler **target) 175 | { 176 | int32 rawchar,mod; 177 | msg->FindInt32("raw_char",&rawchar); 178 | msg->FindInt32("modifiers",&mod); 179 | 180 | BView *view = dynamic_cast(*target); 181 | if (!view || strcmp("_input_",view->Name()) != 0) 182 | return B_DISPATCH_MESSAGE; 183 | 184 | AutoTextControl *text = dynamic_cast(view->Parent()); 185 | if (!text || text != fBox) 186 | return B_DISPATCH_MESSAGE; 187 | 188 | fCurrentMessage = msg; 189 | filter_result result = KeyFilter(rawchar,mod); 190 | fCurrentMessage = NULL; 191 | 192 | if (fBox->fCharLimit && result == B_DISPATCH_MESSAGE) { 193 | // See to it that we still allow shortcut keys 194 | if (mod & B_COMMAND_KEY) 195 | return B_DISPATCH_MESSAGE; 196 | 197 | // We don't use strlen() because it is not UTF-8 aware, which can affect 198 | // how many characters can be typed. 199 | if (isprint(rawchar) && 200 | (uint32)BString(text->Text()).CountChars() == text->fCharLimit) 201 | return B_SKIP_MESSAGE; 202 | } 203 | 204 | return result; 205 | } 206 | 207 | 208 | filter_result 209 | AutoTextControlFilter::KeyFilter(const int32 &rawchar, const int32 &mod) 210 | { 211 | if (fBox) 212 | fBox->Invoke(); 213 | 214 | return B_DISPATCH_MESSAGE; 215 | } 216 | 217 | -------------------------------------------------------------------------------- /volume2/Sources/AutoTextControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | AutoTextControl.h: A BTextControl which notifies on each keypress 3 | Written by DarkWyrm , Copyright 2007 4 | Released under the MIT license. 5 | */ 6 | #ifndef AUTO_TEXT_CONTROL_H 7 | #define AUTO_TEXT_CONTROL_H 8 | 9 | #include 10 | #include 11 | 12 | class AutoTextControlFilter; 13 | 14 | /* 15 | The AutoTextControl provides realtime updates to any changes made to it. 16 | It also provides the ability to limit the text to a certain number of 17 | characters. 18 | 19 | If, for some reason, you want to disable the updates-per-keypress, pass 20 | a regular BMessageFilter to the SetFilter method. 21 | */ 22 | 23 | class AutoTextControl : public BTextControl 24 | { 25 | public: 26 | AutoTextControl(const BRect &frame, const char *name, 27 | const char *label, const char *text, 28 | BMessage *msg, 29 | uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP, 30 | uint32 flags = B_WILL_DRAW | B_NAVIGABLE); 31 | 32 | AutoTextControl(BMessage *data); 33 | static BArchivable * Instantiate(BMessage *data); 34 | virtual status_t Archive(BMessage *data, bool deep = true) const; 35 | 36 | virtual status_t GetSupportedSuites(BMessage *msg); 37 | virtual BHandler * ResolveSpecifier(BMessage *msg, int32 index, 38 | BMessage *specifier, int32 form, 39 | const char *property); 40 | 41 | virtual ~AutoTextControl(void); 42 | 43 | virtual void AttachedToWindow(void); 44 | virtual void DetachedFromWindow(void); 45 | 46 | void SetFilter(AutoTextControlFilter *filter); 47 | AutoTextControlFilter * GetFilter(void) { return fFilter; } 48 | 49 | void SetCharacterLimit(const uint32 &limit); 50 | uint32 GetCharacterLimit(const uint32 &limit); 51 | 52 | void AllowCharacters(const char *string); 53 | void DisallowCharacters(const char *string); 54 | private: 55 | friend class AutoTextControlFilter; 56 | 57 | AutoTextControlFilter *fFilter; 58 | uint32 fCharLimit; 59 | }; 60 | 61 | /* 62 | This class does all of the heavy lifting for AutoTextControl's realtime 63 | updates. 64 | 65 | You can further customize input and updates by subclassing the 66 | KeyFilter hook function. When doing so, the current key message can 67 | be accessed by way of GetCurrentMessage(). However, it will return NULL 68 | when called from any other method. 69 | */ 70 | class AutoTextControlFilter : public BMessageFilter 71 | { 72 | public: 73 | AutoTextControlFilter(AutoTextControl *checkview); 74 | ~AutoTextControlFilter(void); 75 | virtual filter_result Filter(BMessage *msg, BHandler **target); 76 | virtual filter_result KeyFilter(const int32 &key, const int32 &mod); 77 | 78 | AutoTextControl * TextControl(void) const { return fBox; } 79 | BMessage * GetCurrentMessage(void) { return fCurrentMessage; } 80 | private: 81 | AutoTextControl *fBox; 82 | BMessage *fCurrentMessage; 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /volume2/Sources/BQuery Example.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | int 8 | main(void) 9 | { 10 | // Get a BVolume object which represents the boot volume. A BQuery 11 | // object will require one. 12 | BVolumeRoster volRoster; 13 | BVolume bootVolume; 14 | volRoster.GetBootVolume(&bootVolume); 15 | 16 | // A quick summary for using BQuery: 17 | // 1) Make the BQuery object. 18 | // 2) Set the target volume with SetVolume(). 19 | // 3) Specify the search terms with SetPredicate(). 20 | // 4) Call Fetch() to start the search 21 | // 5) Iterate over the results list using GetNextEntry(), 22 | // GetNextRef(), or GetNextDirents(). 23 | 24 | BString predicate("MAIL:subject == *"); 25 | BQuery query; 26 | query.SetVolume(&bootVolume); 27 | query.SetPredicate(predicate.String()); 28 | if (query.Fetch() == B_OK) 29 | { 30 | printf("Results of query \"%s\":\n"); 31 | entry_ref ref; 32 | while (query.GetNextRef(&ref) == B_OK) 33 | printf("\t%s\n",ref.name); 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /volume2/Sources/ColorWell - Draft.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2002-2007, Haiku. All rights reserved. 3 | * Distributed under the terms of the MIT License. 4 | * 5 | * Authors: 6 | * DarkWyrm (darkwyrm@gmail.com) 7 | */ 8 | #ifndef COLOR_WELL_H_ 9 | #define COLOR_WELL_H_ 10 | 11 | #include 12 | 13 | enum 14 | { 15 | COLORWELL_SQUARE_WELL, 16 | COLORWELL_ROUND_WELL, 17 | }; 18 | 19 | class ColorWell : public BControl 20 | { 21 | public: 22 | ColorWell(BRect frame, const char *name, 23 | BMessage *msg, 24 | int32 resize = B_FOLLOW_LEFT | 25 | B_FOLLOW_TOP, 26 | int32 flags = B_WILL_DRAW, 27 | int32 style = COLORWELL_SQUARE_WELL); 28 | ColorWell(BMessage *data); 29 | ~ColorWell(void); 30 | 31 | static BArchivable * Instantiate(BMessage *data); 32 | virtual status_t Archive(BMessage *data, bool deep = true) const; 33 | 34 | virtual status_t GetSupportedSuites(BMessage *msg); 35 | virtual BHandler * ResolveSpecifier(BMessage *msg, int32 index, 36 | BMessage *specifier, int32 form, 37 | const char *property); 38 | 39 | virtual void SetValue(int32 value); 40 | virtual void SetValue(const rgb_color &color); 41 | virtual void SetValue(const uint8 &r, const uint8 &g, 42 | const uint8 &b); 43 | rgb_color ValueAsColor(void) const; 44 | 45 | virtual void SetStyle(const int32 &style); 46 | int32 Style(void) const; 47 | 48 | virtual void MessageReceived(BMessage *msg); 49 | virtual void Draw(BRect update); 50 | 51 | private: 52 | void DrawRound(void); 53 | void DrawSquare(void); 54 | 55 | rgb_color fDisabledColor, 56 | fColor; 57 | 58 | int32 fStyle; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /volume2/Sources/ColorWell - L17.cpp: -------------------------------------------------------------------------------- 1 | #include "ColorWell.h" 2 | 3 | ColorWell::ColorWell(BRect frame, const char *name, BMessage *message, 4 | int32 resize, int32 flags, int32 style) 5 | : BControl(frame,name,NULL,message, resize, flags) 6 | { 7 | SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 8 | SetLowColor(0,0,0); 9 | 10 | fColor.red = 0; 11 | fColor.green = 0; 12 | fColor.blue = 0; 13 | fColor.alpha = 255; 14 | 15 | fDisabledColor.red = 190; 16 | fDisabledColor.green = 190; 17 | fDisabledColor.blue = 190; 18 | fDisabledColor.alpha = 255; 19 | } 20 | 21 | 22 | ColorWell::~ColorWell(void) 23 | { 24 | } 25 | 26 | 27 | void 28 | ColorWell::SetValue(int32 value) 29 | { 30 | BControl::SetValue(value); 31 | 32 | fColor.red = (value & 0xFF000000) >> 24; 33 | fColor.green = (value & 0x00FF0000) >> 16; 34 | fColor.blue = (value & 0x0000FF00) >> 8; 35 | fColor.alpha = 255; 36 | 37 | SetHighColor(fColor); 38 | Draw(Bounds()); 39 | Invalidate(); 40 | } 41 | 42 | 43 | void 44 | ColorWell::SetValue(const rgb_color &col) 45 | { 46 | fColor = col; 47 | fColor.alpha = 255; 48 | fColor.alpha = 255; 49 | 50 | SetHighColor(col); 51 | Draw(Bounds()); 52 | Invalidate(); 53 | } 54 | 55 | 56 | void 57 | ColorWell::SetValue(const uint8 &r,const uint8 &g, const uint8 &b) 58 | { 59 | fColor.red = r; 60 | fColor.green = g; 61 | fColor.blue = b; 62 | 63 | SetHighColor(r,g,b); 64 | Draw(Bounds()); 65 | Invoke(); 66 | } 67 | 68 | 69 | void 70 | ColorWell::SetStyle(const int32 &style) 71 | { 72 | if (style != fStyle) { 73 | fStyle = style; 74 | Invalidate(); 75 | } 76 | } 77 | 78 | 79 | int32 80 | ColorWell::Style(void) const 81 | { 82 | return fStyle; 83 | } 84 | 85 | 86 | void 87 | ColorWell::Draw(BRect update) 88 | { 89 | if (fStyle == COLORWELL_SQUARE_WELL) 90 | DrawSquare(); 91 | else 92 | DrawRound(); 93 | } 94 | 95 | 96 | rgb_color 97 | ColorWell::ValueAsColor(void) const 98 | { 99 | return fColor; 100 | } 101 | 102 | 103 | void 104 | ColorWell::DrawRound(void) 105 | { 106 | BRect r(Bounds().InsetByCopy(1,1)); 107 | 108 | if (IsEnabled()) 109 | { 110 | SetHighColor(fColor); 111 | FillEllipse(Bounds()); 112 | 113 | SetHighColor(0,0,0); 114 | StrokeEllipse(Bounds()); 115 | 116 | } 117 | else 118 | { 119 | SetHighColor(fDisabledColor); 120 | FillEllipse(Bounds()); 121 | 122 | SetHighColor(160,160,160); 123 | StrokeEllipse(Bounds()); 124 | } 125 | } 126 | 127 | 128 | void 129 | ColorWell::DrawSquare(void) 130 | { 131 | BRect r(Bounds()); 132 | 133 | if (IsEnabled()) 134 | { 135 | SetHighColor(fColor); 136 | FillRect(Bounds()); 137 | 138 | SetHighColor(0,0,0); 139 | StrokeRect(Bounds()); 140 | 141 | } 142 | else 143 | { 144 | SetHighColor(fDisabledColor); 145 | FillRect(Bounds()); 146 | 147 | SetHighColor(160,160,160); 148 | StrokeRect(Bounds()); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /volume2/Sources/ColorWell - L17.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_WELL_H 2 | #define COLOR_WELL_H 3 | 4 | #include 5 | 6 | enum 7 | { 8 | COLORWELL_SQUARE_WELL, 9 | COLORWELL_ROUND_WELL, 10 | }; 11 | 12 | class ColorWell : public BControl 13 | { 14 | public: 15 | ColorWell(BRect frame, const char *name, 16 | BMessage *msg, 17 | int32 resize = B_FOLLOW_LEFT | 18 | B_FOLLOW_TOP, 19 | int32 flags = B_WILL_DRAW, 20 | int32 style = COLORWELL_SQUARE_WELL); 21 | ~ColorWell(void); 22 | 23 | virtual void SetValue(int32 value); 24 | virtual void SetValue(const rgb_color &color); 25 | virtual void SetValue(const uint8 &r, const uint8 &g, 26 | const uint8 &b); 27 | rgb_color ValueAsColor(void) const; 28 | 29 | virtual void SetStyle(const int32 &style); 30 | int32 Style(void) const; 31 | 32 | virtual void Draw(BRect update); 33 | 34 | private: 35 | void DrawRound(void); 36 | void DrawSquare(void); 37 | 38 | rgb_color fDisabledColor, 39 | fColor; 40 | 41 | int32 fStyle; 42 | }; 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /volume2/Sources/ColorWell - L19.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORWELL_H 2 | #define COLORWELL_H 3 | 4 | #include 5 | 6 | enum 7 | { 8 | COLORWELL_SQUARE_WELL, 9 | COLORWELL_ROUND_WELL, 10 | }; 11 | 12 | class ColorWell : public BControl 13 | { 14 | public: 15 | ColorWell(BRect frame, const char *name, 16 | BMessage *msg, 17 | int32 resize = B_FOLLOW_LEFT | 18 | B_FOLLOW_TOP, 19 | int32 flags = B_WILL_DRAW, 20 | int32 style = COLORWELL_SQUARE_WELL); 21 | ColorWell(BMessage *data); 22 | ~ColorWell(void); 23 | 24 | virtual status_t GetSupportedSuites(BMessage *msg); 25 | virtual BHandler * ResolveSpecifier(BMessage *msg, int32 index, 26 | BMessage *specifier, int32 form, 27 | const char *property); 28 | 29 | virtual void SetValue(int32 value); 30 | virtual void SetValue(const rgb_color &color); 31 | virtual void SetValue(const uint8 &r, const uint8 &g, 32 | const uint8 &b); 33 | rgb_color ValueAsColor(void) const; 34 | 35 | virtual void SetStyle(const int32 &style); 36 | int32 Style(void) const; 37 | 38 | virtual void MessageReceived(BMessage *msg); 39 | virtual void Draw(BRect update); 40 | 41 | private: 42 | void DrawRound(void); 43 | void DrawSquare(void); 44 | 45 | rgb_color fDisabledColor, 46 | fColor; 47 | 48 | int32 fStyle; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /volume2/Sources/ColorWell - L20.h: -------------------------------------------------------------------------------- 1 | #ifndef COLORWELL_H 2 | #define COLORWELL_H 3 | 4 | #include 5 | 6 | enum 7 | { 8 | COLORWELL_SQUARE_WELL, 9 | COLORWELL_ROUND_WELL, 10 | }; 11 | 12 | class ColorWell : public BControl 13 | { 14 | public: 15 | ColorWell(BRect frame, const char *name, 16 | BMessage *msg, 17 | int32 resize = B_FOLLOW_LEFT | 18 | B_FOLLOW_TOP, 19 | int32 flags = B_WILL_DRAW, 20 | int32 style = COLORWELL_SQUARE_WELL); 21 | ColorWell(BMessage *data); 22 | ~ColorWell(void); 23 | 24 | virtual status_t GetSupportedSuites(BMessage *msg); 25 | virtual BHandler * ResolveSpecifier(BMessage *msg, int32 index, 26 | BMessage *specifier, int32 form, 27 | const char *property); 28 | 29 | virtual void SetValue(int32 value); 30 | virtual void SetValue(const rgb_color &color); 31 | virtual void SetValue(const uint8 &r, const uint8 &g, 32 | const uint8 &b); 33 | rgb_color ValueAsColor(void) const; 34 | 35 | virtual void SetStyle(const int32 &style); 36 | int32 Style(void) const; 37 | 38 | virtual void MouseDown(BPoint pt); 39 | virtual void MessageReceived(BMessage *msg); 40 | virtual void Draw(BRect update); 41 | 42 | private: 43 | void DrawRound(void); 44 | void DrawSquare(void); 45 | 46 | rgb_color fDisabledColor, 47 | fColor; 48 | 49 | int32 fStyle; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /volume2/Sources/DragView.cpp: -------------------------------------------------------------------------------- 1 | #include "DragView.h" 2 | 3 | enum 4 | { 5 | M_DRAG = 'drag' 6 | }; 7 | 8 | 9 | DragView::DragView(BRect frame) 10 | : BView(frame, "dragview", B_FOLLOW_LEFT | B_FOLLOW_TOP, 11 | B_WILL_DRAW), 12 | fDragRect(10, 10, 50, 50) 13 | { 14 | } 15 | 16 | 17 | void 18 | DragView::MouseDown(BPoint pt) 19 | { 20 | // For our example, we only support dragging with the left button 21 | BPoint temp; 22 | uint32 buttons; 23 | GetMouse(&temp, &buttons); 24 | 25 | if (fDragRect.Contains(temp)) 26 | { 27 | // SetMouseEventMask can only be called from within 28 | // MouseDown(). It forces all mouse events to be sent to this 29 | // view until the button is released. This saves us from having 30 | // to manually code the mouse tracking. 31 | SetMouseEventMask(B_POINTER_EVENTS, 0); 32 | 33 | BMessage dragMsg(M_DRAG); 34 | dragMsg.AddInt32("buttons", buttons); 35 | DragMessage(&dragMsg, fDragRect); 36 | 37 | // If you allocate the drag message on the heap, make sure 38 | // you delete it after DragMessage() returns. If you use a 39 | // BBitmap version of DrawMessage(), DON'T delete the bitmap 40 | // after calling DragMessage() because the system will do 41 | // that for you. 42 | } 43 | 44 | } 45 | 46 | 47 | void 48 | DragView::Draw(BRect update) 49 | { 50 | SetHighColor(0, 0, 160); 51 | FillRect(fDragRect); 52 | 53 | DrawString("Try dragging the square", BPoint(fDragRect.left, 54 | fDragRect.bottom + 50)); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /volume2/Sources/DragView.h: -------------------------------------------------------------------------------- 1 | #ifndef DRAGVIEW_H 2 | #define DRAGVIEW_H 3 | 4 | #include 5 | 6 | class DragView : public BView 7 | { 8 | public: 9 | DragView(BRect frame); 10 | void MouseDown(BPoint pt); 11 | void Draw(BRect update); 12 | 13 | private: 14 | BRect fDragRect; 15 | }; 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.test-FontDemo1") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/FontDemo1.pld: -------------------------------------------------------------------------------- 1 | NAME=FontDemo1 2 | TARGETNAME=FontDemo1 3 | PLATFORM=Haiku 4 | SCM=none 5 | GROUP=Source Files 6 | EXPANDGROUP=yes 7 | SOURCEFILE=App.cpp 8 | DEPENDENCY=/boot/home/Desktop/BookSources/FontDemo1/App.h|/boot/home/Desktop/BookSources/FontDemo1/MainWindow.h 9 | SOURCEFILE=MainView.cpp 10 | DEPENDENCY=/boot/home/Desktop/BookSources/FontDemo1/MainView.h 11 | SOURCEFILE=MainWindow.cpp 12 | DEPENDENCY=/boot/home/Desktop/BookSources/FontDemo1/MainWindow.h|/boot/home/Desktop/BookSources/FontDemo1/MainView.h 13 | SYSTEMINCLUDE=/boot/develop/headers/be 14 | SYSTEMINCLUDE=/boot/develop/headers/cpp 15 | SYSTEMINCLUDE=/boot/develop/headers/posix 16 | SYSTEMINCLUDE=/boot/home/config/include 17 | LIBRARY=/boot/develop/lib/x86/libroot.so 18 | LIBRARY=/boot/develop/lib/x86/libbe.so 19 | RUNARGS= 20 | CCDEBUG=no 21 | CCPROFILE=no 22 | CCOPSIZE=no 23 | CCOPLEVEL=0 24 | CCTARGETTYPE=0 25 | CCEXTRA= 26 | LDEXTRA= 27 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/MainView.cpp: -------------------------------------------------------------------------------- 1 | #include "MainView.h" 2 | 3 | MainView::MainView(const BRect &frame) 4 | : BView(frame, "textview", B_FOLLOW_ALL, B_WILL_DRAW) 5 | { 6 | } 7 | 8 | 9 | void 10 | MainView::Draw(BRect update) 11 | { 12 | // The Draw hook function is called whenever a BView is asked to redraw 13 | // itself on the screen. We will just write some code to draw some text. 14 | BFont font; 15 | font.SetSize(18.0); 16 | 17 | // Just setting values to our font object isn't enough. We have to assign 18 | // the BView's font settings to the values kept in our font object. 19 | SetFont(&font); 20 | 21 | // DrawString uses the BView's current font settings, draw mode, and 22 | // color to draw the text. Note that the point specified is the left 23 | // end of the baseline, so calculating where to draw text can be a 24 | // little backwards when compared to drawing anything else. 25 | DrawString("This is some text", BPoint(50,50)); 26 | } 27 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/MainView.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINVIEW_H 2 | #define MAINVIEW_H 3 | 4 | #include 5 | 6 | class MainView : public BView 7 | { 8 | public: 9 | MainView(const BRect &frame); 10 | void Draw(BRect update); 11 | }; 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "MainView.h" 8 | 9 | MainWindow::MainWindow(void) 10 | : BWindow(BRect(100,100,500,400),"Font Demo #1",B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS) 11 | { 12 | BRect r(Bounds()); 13 | r.bottom = 20; 14 | fMenuBar = new BMenuBar(r,"menubar"); 15 | AddChild(fMenuBar); 16 | 17 | r = Bounds(); 18 | r.top = 20; 19 | MainView *view = new MainView(r); 20 | AddChild(view); 21 | } 22 | 23 | 24 | void 25 | MainWindow::MessageReceived(BMessage *msg) 26 | { 27 | switch (msg->what) 28 | { 29 | default: 30 | { 31 | BWindow::MessageReceived(msg); 32 | break; 33 | } 34 | } 35 | } 36 | 37 | 38 | bool 39 | MainWindow::QuitRequested(void) 40 | { 41 | be_app->PostMessage(B_QUIT_REQUESTED); 42 | return true; 43 | } 44 | -------------------------------------------------------------------------------- /volume2/Sources/FontDemo/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | class MainWindow : public BWindow 8 | { 9 | public: 10 | MainWindow(void); 11 | void MessageReceived(BMessage *msg); 12 | bool QuitRequested(void); 13 | 14 | private: 15 | BMenuBar *fMenuBar; 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /volume2/Sources/GetEmailName.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | BString 6 | GetEmailName(const char *path) 7 | { 8 | BString out; 9 | BNode node(path); 10 | if (node.InitCheck() != B_OK) 11 | return out; 12 | 13 | // This is to make sure that the attribute exists and what 14 | // its size is. 15 | attr_info attrInfo; 16 | if (node.GetAttrInfo("META:name", &attrInfo) != B_OK) 17 | return out; 18 | 19 | // BString::LockBuffer() and UnlockBuffer() allow us to have 20 | // direct access to the internal character buffer that the BString 21 | // uses. LockBuffer() takes one parameter which is the maximum 22 | // size that the character buffer needs to be. 23 | char *nameBuffer = out.LockBuffer(attrInfo.size + 1); 24 | node.ReadAttr("META:name", attrInfo.type, 0, nameBuffer, 25 | attrInfo.size); 26 | nameBuffer[attrInfo.size] = '\0'; 27 | out.UnlockBuffer(); 28 | 29 | return out; 30 | } 31 | 32 | int 33 | main(void) 34 | { 35 | } 36 | -------------------------------------------------------------------------------- /volume2/Sources/LibWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBWINDOW_H 2 | #define LIBWINDOW_H 3 | 4 | #include "DWindow.h" 5 | #include 6 | 7 | class Project; 8 | 9 | #define M_LIBWIN_CLOSED 'lwcl' 10 | 11 | class LibraryWindow : public DWindow 12 | { 13 | public: 14 | LibraryWindow(BRect frame, const BMessenger &parent, 15 | Project *project); 16 | ~LibraryWindow(void); 17 | bool QuitRequested(void); 18 | void MessageReceived(BMessage *msg); 19 | 20 | private: 21 | BView * AddHeader(BPoint location, const char *label); 22 | BRect ScanFolder(BPoint location, const char *dir, float *maxwidth); 23 | static int32 ScanThread(void *data); 24 | 25 | BView *fCheckList; 26 | 27 | BMessenger fParent; 28 | Project *fProject; 29 | BList fSystemLibs, 30 | fUserLibs; 31 | thread_id fScanThread; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /volume2/Sources/Push BQuery Example.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int 9 | main(void) 10 | { 11 | // Get a BVolume object which represents the boot volume. A BQuery 12 | // object will require one. 13 | BVolumeRoster volRoster; 14 | BVolume bootVolume; 15 | volRoster.GetBootVolume(&bootVolume); 16 | 17 | // A quick summary for using BQuery: 18 | // 1) Make the BQuery object. 19 | // 2) Set the target volume with SetVolume(). 20 | // 3) Specify the search terms with SetPredicate(). 21 | // 4) Call Fetch() to start the search 22 | // 5) Iterate over the results list using GetNextEntry(), 23 | // GetNextRef(), or GetNextDirents(). 24 | 25 | BString predicate("MAIL:subject == *"); 26 | BQuery query; 27 | query.SetVolume(&bootVolume); 28 | query.PushAttr("MAIL:subject"); 29 | query.PushString("*"); 30 | query.PushOp(B_EQ); 31 | if (query.Fetch() == B_OK) 32 | { 33 | printf("Results of query \"%s\":\n", predicate.String()); 34 | entry_ref ref; 35 | while (query.GetNextRef(&ref) == B_OK) 36 | printf("\t%s\n",ref.name); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L22/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-QuickEdit") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L22/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L22/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | class MainWindow : public BWindow 13 | { 14 | public: 15 | MainWindow(void); 16 | ~MainWindow(void); 17 | 18 | void MessageReceived(BMessage *msg); 19 | bool QuitRequested(void); 20 | 21 | void OpenFile(const entry_ref &ref); 22 | void SaveFile(const char *path); 23 | 24 | void FrameResized(float w, float h); 25 | private: 26 | void UpdateTextRect(void); 27 | 28 | BMenuBar *fMenuBar; 29 | BTextView *fTextView; 30 | BFilePanel *fOpenPanel, 31 | *fSavePanel; 32 | 33 | BString fFilePath; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L22/QuickEdit L22.pld: -------------------------------------------------------------------------------- 1 | NAME=QuickEdit L22 2 | TARGETNAME=QuickEdit 3 | PLATFORM=HaikuGCC4 4 | SCM=none 5 | GROUP=Source Files 6 | EXPANDGROUP=yes 7 | SOURCEFILE=App.cpp 8 | DEPENDENCY=/boot/home/projects/PrintWorld/App.h|/boot/home/projects/PrintWorld/MainWindow.h 9 | SOURCEFILE=MainWindow.cpp 10 | DEPENDENCY=/boot/home/projects/PrintWorld/MainWindow.h|/boot/home/projects/PrintWorld/MainView.h 11 | SOURCEFILE=Resources.rsrc 12 | SYSTEMINCLUDE=/boot/develop/headers/be 13 | SYSTEMINCLUDE=/boot/develop/headers/cpp 14 | SYSTEMINCLUDE=/boot/develop/headers/posix 15 | SYSTEMINCLUDE=/boot/home/config/include 16 | LIBRARY=/boot/develop/lib/x86/libroot.so 17 | LIBRARY=/boot/develop/lib/x86/libbe.so 18 | LIBRARY=/boot/develop/lib/x86/libsupc++.so 19 | LIBRARY=/boot/system/lib/libsupc++.so 20 | LIBRARY=/boot/develop/lib/x86/libtranslation.so 21 | LIBRARY=/boot/develop/lib/x86/libtracker.so 22 | RUNARGS= 23 | CCDEBUG=no 24 | CCPROFILE=no 25 | CCOPSIZE=no 26 | CCOPLEVEL=0 27 | CCTARGETTYPE=0 28 | CCEXTRA= 29 | LDEXTRA= 30 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L22/QuickEdit.pld: -------------------------------------------------------------------------------- 1 | NAME=QuickEdit 2 | TARGETNAME=QuickEdit 3 | PLATFORM=HaikuGCC4 4 | SCM=hg 5 | GROUP=Source Files 6 | EXPANDGROUP=yes 7 | SOURCEFILE=App.cpp 8 | DEPENDENCY=/boot/home/projects/PrintWorld/App.h|/boot/home/projects/PrintWorld/MainWindow.h 9 | SOURCEFILE=EditView.cpp 10 | DEPENDENCY=/boot/home/projects/QuickEdit/EditView.h 11 | SOURCEFILE=MainWindow.cpp 12 | DEPENDENCY=/boot/home/projects/PrintWorld/MainWindow.h|/boot/home/projects/PrintWorld/MainView.h 13 | SOURCEFILE=Resources.rsrc 14 | SYSTEMINCLUDE=/boot/develop/headers/be 15 | SYSTEMINCLUDE=/boot/develop/headers/cpp 16 | SYSTEMINCLUDE=/boot/develop/headers/posix 17 | SYSTEMINCLUDE=/boot/home/config/include 18 | LIBRARY=/boot/develop/lib/x86/libroot.so 19 | LIBRARY=/boot/develop/lib/x86/libbe.so 20 | LIBRARY=/boot/develop/lib/x86/libsupc++.so 21 | LIBRARY=/boot/system/lib/libsupc++.so 22 | LIBRARY=/boot/develop/lib/x86/libtranslation.so 23 | LIBRARY=/boot/develop/lib/x86/libtracker.so 24 | RUNARGS= 25 | CCDEBUG=no 26 | CCPROFILE=no 27 | CCOPSIZE=no 28 | CCOPLEVEL=0 29 | CCTARGETTYPE=0 30 | CCEXTRA= 31 | LDEXTRA= 32 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L22/Resources.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/QuickEdit - L22/Resources.rsrc -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-QuickEdit") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/EditView.cpp: -------------------------------------------------------------------------------- 1 | #include "EditView.h" 2 | 3 | EditView::EditView(const BRect &frame, const char *name, const int32 &resize) 4 | : BTextView(frame, name, frame, resize), 5 | fNotifyChanges(true) 6 | { 7 | SetFlags(Flags() | B_FRAME_EVENTS); 8 | UpdateTextRect(); 9 | 10 | SetMessage(new BMessage(M_TEXT_CHANGED)); 11 | } 12 | 13 | 14 | void 15 | EditView::FrameResized(float w, float h) 16 | { 17 | UpdateTextRect(); 18 | } 19 | 20 | 21 | void 22 | EditView::UpdateTextRect(void) 23 | { 24 | BRect r(Bounds()); 25 | r.InsetBy(5, 5); 26 | 27 | SetTextRect(r); 28 | } 29 | 30 | 31 | void 32 | EditView::InsertText(const char *inText, int32 inLength, int32 inOffset, 33 | const text_run_array *inRuns) 34 | { 35 | BTextView::InsertText(inText, inLength, inOffset, inRuns); 36 | 37 | if (IsNotifyingChanges()) 38 | Invoke(); 39 | } 40 | 41 | 42 | void 43 | EditView::DeleteText(int32 fromOffset, int32 toOffset) 44 | { 45 | BTextView::DeleteText(fromOffset, toOffset); 46 | 47 | if (IsNotifyingChanges()) 48 | Invoke(); 49 | } 50 | 51 | 52 | void 53 | EditView::SetChangeNotifications(bool value) 54 | { 55 | fNotifyChanges = value; 56 | } 57 | 58 | 59 | bool 60 | EditView::IsNotifyingChanges(void) const 61 | { 62 | return fNotifyChanges; 63 | } 64 | 65 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/EditView.h: -------------------------------------------------------------------------------- 1 | #ifndef EDITVIEW_H 2 | #define EDITVIEW_H 3 | 4 | #include 5 | #include 6 | 7 | enum 8 | { 9 | M_TEXT_CHANGED = 'txch' 10 | }; 11 | 12 | class EditView : public BTextView, public BInvoker 13 | { 14 | public: 15 | EditView(const BRect &frame, const char *name, 16 | const int32 &resize); 17 | 18 | void FrameResized(float w, float h); 19 | 20 | virtual void InsertText(const char *inText, int32 inLength, 21 | int32 inOffset, 22 | const text_run_array *inRuns); 23 | 24 | virtual void DeleteText(int32 fromOffset, int32 toOffset); 25 | 26 | void SetChangeNotifications(bool value); 27 | bool IsNotifyingChanges(void) const; 28 | private: 29 | void UpdateTextRect(void); 30 | 31 | bool fNotifyChanges; 32 | }; 33 | 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class EditView; 12 | 13 | class MainWindow : public BWindow 14 | { 15 | public: 16 | MainWindow(void); 17 | ~MainWindow(void); 18 | 19 | void MessageReceived(BMessage *msg); 20 | bool QuitRequested(void); 21 | 22 | void OpenFile(const entry_ref &ref); 23 | void SaveFile(const char *path); 24 | 25 | private: 26 | bool AlertChanges(void); 27 | void DoPageSetup(void); 28 | void DoPrint(void); 29 | 30 | BMenuBar *fMenuBar; 31 | EditView *fTextView; 32 | BFilePanel *fOpenPanel, 33 | *fSavePanel; 34 | 35 | BMessage *fPageSetup; 36 | 37 | BString fFilePath; 38 | bool fChanged; 39 | bool fQuitAfterSave; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/QuickEdit.pld: -------------------------------------------------------------------------------- 1 | NAME=QuickEdit 2 | TARGETNAME=QuickEdit 3 | PLATFORM=HaikuGCC4 4 | SCM=hg 5 | GROUP=Source Files 6 | EXPANDGROUP=yes 7 | SOURCEFILE=App.cpp 8 | DEPENDENCY=/boot/home/projects/PrintWorld/App.h|/boot/home/projects/PrintWorld/MainWindow.h 9 | SOURCEFILE=EditView.cpp 10 | DEPENDENCY=/boot/home/projects/QuickEdit/EditView.h 11 | SOURCEFILE=MainWindow.cpp 12 | DEPENDENCY=/boot/home/projects/PrintWorld/MainWindow.h|/boot/home/projects/PrintWorld/MainView.h 13 | SOURCEFILE=Resources.rsrc 14 | SYSTEMINCLUDE=/boot/develop/headers/be 15 | SYSTEMINCLUDE=/boot/develop/headers/cpp 16 | SYSTEMINCLUDE=/boot/develop/headers/posix 17 | SYSTEMINCLUDE=/boot/home/config/include 18 | LIBRARY=/boot/develop/lib/x86/libroot.so 19 | LIBRARY=/boot/develop/lib/x86/libbe.so 20 | LIBRARY=/boot/develop/lib/x86/libsupc++.so 21 | LIBRARY=/boot/system/lib/libsupc++.so 22 | LIBRARY=/boot/develop/lib/x86/libtranslation.so 23 | LIBRARY=/boot/develop/lib/x86/libtracker.so 24 | RUNARGS= 25 | CCDEBUG=no 26 | CCPROFILE=no 27 | CCOPSIZE=no 28 | CCOPLEVEL=0 29 | CCTARGETTYPE=0 30 | CCEXTRA= 31 | LDEXTRA= 32 | -------------------------------------------------------------------------------- /volume2/Sources/QuickEdit - L23/Resources.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/QuickEdit - L23/Resources.rsrc -------------------------------------------------------------------------------- /volume2/Sources/ReadProject.cpp: -------------------------------------------------------------------------------- 1 | // This is intended to be a cross-platform way of reading Paladin 2 | // projects, so we won't be using the Haiku API. This is strictly 3 | // C++ methods. 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // Because we're doing so much in the std namespace, this will save 14 | // us a *lot* of extra typing. 15 | using namespace std; 16 | 17 | // True, these could (and probably should) be classes, we will just 18 | // use structures for the sake of space and simplicity. 19 | typedef struct 20 | { 21 | string path; 22 | string dependencies; 23 | 24 | } ProjectFile; 25 | 26 | 27 | typedef struct 28 | { 29 | string name; 30 | bool expanded; 31 | vector files; 32 | 33 | } ProjectGroup; 34 | 35 | 36 | // The actual Project class used by Paladin is much more 37 | // complicated because it also has some properties for 38 | // maintaining state while the program is running, but 39 | // this structure has all of the data that is used for 40 | // building and maintaining a project. 41 | typedef struct 42 | { 43 | map properties; 44 | 45 | vector localIncludes; 46 | vector systemIncludes; 47 | vector groups; 48 | vector libraries; 49 | 50 | } PaladinProject; 51 | 52 | 53 | int 54 | ReadPaladinProject(const char *path, PaladinProject &proj) 55 | { 56 | // Create an Input File Stream for reading the file 57 | ifstream file; 58 | 59 | file.open(path, ifstream::in); 60 | if (!file.is_open()) 61 | { 62 | // endl is a cross-platform stand-in for an end-of-line 63 | // character. The EOL character is different on Windows, 64 | // Haiku/Linux/UNIX, and OS X and this saves us from 65 | // having to figure it out without sacrificing portability. 66 | cout << "Couldn't open the file " << path << endl; 67 | return -1; 68 | } 69 | 70 | // Empty the project's data to make sure we're not building 71 | // upon existing baggage. 72 | proj.properties.clear(); 73 | proj.localIncludes.clear(); 74 | proj.systemIncludes.clear(); 75 | proj.groups.clear(); 76 | 77 | while (!file.eof()) 78 | { 79 | string strData; 80 | 81 | // While the fstream class has a getline() method, it only 82 | // works on regular strings. There is a global getline() 83 | // function in which reads data from a stream into 84 | // a C++ string. This is the version that we will use. 85 | getline(file, strData); 86 | 87 | // An empty line shouldn't exist in a Paladin project, but 88 | // let's handle the case just to prevent headaches. 89 | if (strData.empty()) 90 | continue; 91 | 92 | size_t pos = strData.find('='); 93 | 94 | // npos is the maximum size for a C++ string. find() will 95 | // return npos if the string searched for is not found. 96 | if (pos == string::npos) 97 | continue; 98 | 99 | string key = strData.substr(0, pos); 100 | string value = strData.substr(pos + 1, string::npos); 101 | 102 | if (key.compare("GROUP") == 0) 103 | { 104 | // Using vectors saves us from having to worry about memory 105 | // management and pointers. Instead, all that we have to do 106 | // is create a new group on the stack which will be used 107 | // to initialize the new element in the groups vector. 108 | ProjectGroup newGroup; 109 | newGroup.name = value; 110 | proj.groups.push_back(newGroup); 111 | 112 | } 113 | else if (key.compare("EXPANDGROUP") == 0) 114 | { 115 | if (!proj.groups.empty()) 116 | proj.groups.back().expanded = strcasecmp(value.c_str(), "yes"); 117 | } 118 | else if (key.compare("SOURCEFILE") == 0) 119 | { 120 | // Quite a few dots are used to create the new file, but that's OK. 121 | // It sure beats messing around with pointers. 122 | ProjectFile newFile; 123 | newFile.path = value; 124 | proj.groups.back().files.push_back(newFile); 125 | } 126 | else if (key.compare("DEPENDENCY") == 0) 127 | proj.groups.back().files.back().dependencies = value; 128 | else if (key.compare("LIBRARY") == 0) 129 | proj.libraries.push_back(value); 130 | else 131 | proj.properties[key] = value; 132 | } 133 | 134 | return 0; 135 | } 136 | 137 | 138 | int 139 | main(int argc, char **argv) 140 | { 141 | PaladinProject project; 142 | 143 | if (argc == 2) 144 | ReadPaladinProject(argv[1], project); 145 | else 146 | cout << "Usage: " << argv[0] << " \n"; 147 | 148 | map::iterator i; 149 | for (i = project.properties.begin(); i != project.properties.end(); i++) 150 | cout << i->first << ": " << i->second << endl; 151 | 152 | return 0; 153 | } 154 | 155 | -------------------------------------------------------------------------------- /volume2/Sources/Resource Template.rdef: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------- 2 | Change the value in quotes to match the signature passed 3 | to the BApplication constructor by your program. 4 | --------------------------------------------------------------------*/ 5 | resource app_signature "application/x-vnd.me-MyAppSignature"; 6 | 7 | /*-------------------------------------------------------------------- 8 | Value for app flags can be B_SINGLE_LAUNCH, B_MULTIPLE_LAUNCH, or 9 | B_EXCLUSIVE_LAUNCH. 10 | 11 | Additionally, you may also add the B_BACKGROUND_APP or 12 | B_ARGV_ONLY flags via a pipe symbol, such as the following: 13 | B_SINGLE_LAUNCH | B_BACKGROUND_APP 14 | 15 | B_SINGLE_LAUNCH is the normal OS behavior 16 | --------------------------------------------------------------------*/ 17 | resource app_flags B_SINGLE_LAUNCH; 18 | 19 | /*-------------------------------------------------------------------- 20 | Set the version information about your app here. 21 | The variety can be set to one of the following values 22 | B_APPV_DEVELOPMENT, 23 | B_APPV_ALPHA, 24 | B_APPV_BETA, 25 | B_APPV_GAMMA, 26 | B_APPV_GOLDEN_MASTER, 27 | B_APPV_FINAL 28 | --------------------------------------------------------------------*/ 29 | resource app_version { 30 | major = 0, 31 | middle = 0, 32 | minor = 1, 33 | 34 | variety = B_APPV_DEVELOPMENT, 35 | internal = 0, 36 | 37 | short_info = "A short app description", 38 | long_info = "A longer app description" 39 | }; 40 | 41 | resource large_icon array { 42 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 43 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 44 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 45 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 46 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 47 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 48 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 49 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 50 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 51 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 52 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 53 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 54 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 55 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 56 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 57 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 58 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 59 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 60 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 61 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 62 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 63 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 64 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 65 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 66 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 67 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 68 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 69 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 70 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 71 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 72 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 73 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 74 | }; 75 | 76 | resource mini_icon array { 77 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 78 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 79 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 80 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 81 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 82 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 83 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 84 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 85 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 86 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 87 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 88 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 89 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 90 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 91 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 92 | $"1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C" 93 | }; 94 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/00changelog.i: -------------------------------------------------------------------------------- 1 |  dummy changelog to prevent using the old repo layout -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/branchheads.cache: -------------------------------------------------------------------------------- 1 | 193ba11fa6844dbf7b27bcdb421439bdff9786c8 6 2 | 193ba11fa6844dbf7b27bcdb421439bdff9786c8 default 3 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/dirstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/dirstate -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/last-message.txt: -------------------------------------------------------------------------------- 1 | Revert the build fix for Zeta which is not compatible with Haiku 2 | 3 | HG: 4 | HG: All lines starting with HG: will be ignored. 5 | HG: ---------------------------------------------------- 6 | HG: M PropDump.cpp 7 | HG: ? ZetaNotes.txt 8 | HG: -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/requires: -------------------------------------------------------------------------------- 1 | revlogv1 2 | store 3 | fncache 4 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/00changelog.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/00changelog.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/00manifest.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/00manifest.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/.hgignore.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/.hgignore.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_prop_dump.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_prop_dump.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_prop_dump.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_prop_dump.h.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_view.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_view.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_view.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_view.h.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_window.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_window.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_window.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_window.h.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.h.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.pld.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.pld.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.rsrc.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_script_world.rsrc.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_send_panel.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_send_panel.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/data/_send_panel.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/store/data/_send_panel.h.i -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/fncache: -------------------------------------------------------------------------------- 1 | data/PropDump.cpp.i 2 | data/PropDump.h.i 3 | data/ScriptView.cpp.i 4 | data/ScriptView.h.i 5 | data/ScriptWindow.cpp.i 6 | data/ScriptWindow.h.i 7 | data/ScriptWorld.cpp.i 8 | data/ScriptWorld.h.i 9 | data/ScriptWorld.rsrc.i 10 | data/SendPanel.cpp.i 11 | data/SendPanel.h.i 12 | data/ScriptWorld.pld.i 13 | data/.hgignore.i 14 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/store/undo: -------------------------------------------------------------------------------- 1 | data/PropDump.cpp.i2064 2 | 00manifest.i1564 3 | 00changelog.i1475 4 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/tags.cache: -------------------------------------------------------------------------------- 1 | 6 193ba11fa6844dbf7b27bcdb421439bdff9786c8 2 | 3 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/undo.branch: -------------------------------------------------------------------------------- 1 | default -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/undo.desc: -------------------------------------------------------------------------------- 1 | 6 2 | commit 3 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hg/undo.dirstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/.hg/undo.dirstate -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/.hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | (Objects.* 3 | *.dbg 4 | ScriptWorld 5 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/PropDump.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 1999, Be Incorporated. All Rights Reserved. 3 | This file may be used under the terms of the Be Sample Code License. 4 | */ 5 | 6 | #ifndef _propdump_h 7 | #define _propdump_h 8 | 9 | #include 10 | #include 11 | 12 | enum 13 | { 14 | MSG_IS_SPEC = 0x00000001, 15 | MSG_IS_CMD = 0x00000002 16 | }; 17 | 18 | BString DumpMessage(const BMessage* msg, uint32 dumpFlags = 0, 19 | int32 pprint = 0); 20 | 21 | BString DumpMessageField(const BMessage* msg, const char* name, 22 | type_code type, int32 count, uint32 dumpFlags, 23 | int32 pprint); 24 | 25 | BString DumpPropInfo(const BPropertyInfo* info, int32 pprint); 26 | BString GetCommandName(type_code command); 27 | BString GetSpecName(type_code spec); 28 | 29 | #endif /* _propdump_h */ 30 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ScriptView.cpp 3 | 4 | Copyright 1997 Be Incorporated, All Rights Reserved. 5 | Copyright 1999, Be Incorporated. All Rights Reserved. 6 | This file may be used under the terms of the Be Sample Code License. 7 | */ 8 | 9 | #include "ScriptView.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "PropDump.h" 17 | #include "SendPanel.h" 18 | 19 | const bigtime_t HUGE_TIMEOUT = 1000000; 20 | 21 | ScriptView::ScriptView(BRect rect, const char *name) 22 | : BOutlineListView(rect, name, B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL) 23 | { 24 | BMessage *msg = new BMessage ('invk'); 25 | SetInvocationMessage(msg); 26 | } 27 | 28 | 29 | status_t 30 | ScriptView::FillList() 31 | { 32 | BString name; 33 | int32 wincount, viewcount; 34 | BMessage reply; 35 | BList teams; 36 | status_t result; 37 | 38 | be_roster->GetAppList(&teams); 39 | int32 n = teams.CountItems(); 40 | for(int32 i=0; i= 0 || name.IFindLast("_server") >= 0 || 55 | name == "registrar") 56 | continue; 57 | 58 | BStringItem *app = new BStringItem(name.String(), 0, false); 59 | AddItem(app); 60 | 61 | // ask for Window Count 62 | BMessage count_msg(B_COUNT_PROPERTIES); 63 | count_msg.AddSpecifier("Window"); 64 | if (msgr.SendMessage(&count_msg, &reply, HUGE_TIMEOUT, HUGE_TIMEOUT) != B_OK) 65 | continue; 66 | 67 | if (reply.FindInt32("result", 0, &wincount) != B_OK) 68 | continue; 69 | 70 | for(int i=0; i < wincount; i++) 71 | { 72 | BMessage winname_msg(B_GET_PROPERTY); 73 | winname_msg.AddSpecifier("Title"); 74 | winname_msg.AddSpecifier("Window", i); 75 | if (msgr.SendMessage(&winname_msg, &reply, HUGE_TIMEOUT, HUGE_TIMEOUT) != B_OK) 76 | continue; 77 | 78 | result = reply.FindString("result", 0, &name); 79 | if(result == B_OK) 80 | { 81 | BStringItem *winname = new BStringItem(name.String(), 1, false); 82 | AddItem(winname); 83 | } 84 | 85 | // count Views 86 | BMessage view_msg(B_COUNT_PROPERTIES); 87 | view_msg.AddSpecifier("View"); 88 | view_msg.AddSpecifier("Window", i); 89 | if (msgr.SendMessage(&view_msg, &reply, HUGE_TIMEOUT, HUGE_TIMEOUT) != B_OK) 90 | continue; 91 | 92 | if (reply.FindInt32("result", 0, &viewcount) != B_OK) 93 | continue; 94 | 95 | // ask for View Names 96 | for(int j=0; j < viewcount; j++) 97 | { 98 | BMessage viewname_msg(B_GET_PROPERTY); 99 | viewname_msg.AddSpecifier("InternalName"); 100 | viewname_msg.AddSpecifier("View", j); 101 | viewname_msg.AddSpecifier("Window", i); 102 | 103 | if (msgr.SendMessage(&viewname_msg, &reply, HUGE_TIMEOUT, HUGE_TIMEOUT) != B_OK) 104 | break; 105 | 106 | // reply.PrintToStream(); 107 | 108 | if(reply.FindString("result", 0, &name) != B_OK) 109 | break; 110 | 111 | BStringItem *viewname = new BStringItem(name.String(), 2, false); 112 | AddItem(viewname); 113 | } 114 | } 115 | } 116 | return B_OK; 117 | } 118 | 119 | 120 | status_t 121 | ScriptView::Invoke(BMessage *msg) 122 | { 123 | const char *name; 124 | BMessenger *sendto = new BMessenger; 125 | BMessage script_msg(B_GET_PROPERTY); 126 | BStringItem *temp; 127 | BList teams; 128 | BMessage reply; 129 | status_t result; 130 | 131 | script_msg.AddSpecifier("Messenger"); 132 | 133 | int32 index = CurrentSelection(); 134 | BStringItem *item = (BStringItem *)ItemAt(index); 135 | if(item->OutlineLevel() == 2) 136 | { 137 | script_msg.AddSpecifier("View", item->Text()); 138 | temp = (BStringItem *)Superitem(item); 139 | item = temp; 140 | } 141 | if(item->OutlineLevel() == 1) 142 | { 143 | script_msg.AddSpecifier("Window", item->Text()); 144 | temp = (BStringItem *)Superitem(item); 145 | item = temp; 146 | } 147 | if(item->OutlineLevel() == 0) 148 | { 149 | be_roster->GetAppList(&teams); 150 | int n = teams.CountItems(); 151 | for(int i=0; iText()) < 1 ) 164 | { 165 | // get a messenger for this object 166 | printf("string compare\n"); 167 | script_msg.PrintToStream(); 168 | result = msgr.SendMessage(&script_msg, &reply, HUGE_TIMEOUT, HUGE_TIMEOUT); 169 | if (result == B_OK) 170 | { 171 | reply.PrintToStream(); 172 | result = reply.FindMessenger("result", sendto); 173 | if(result == B_OK) 174 | { 175 | BRect frame(Window()->Frame()); 176 | BRect screen(BScreen().Frame()); 177 | 178 | frame.OffsetTo(frame.right + 10.0, frame.top); 179 | frame.right = frame.left + 430; 180 | frame.bottom = frame.top + 300; 181 | if (frame.right > screen.right) 182 | frame.OffsetBy(screen.right - frame.right - 10, 0); 183 | 184 | SendPanel *panel = new SendPanel(sendto, &frame); 185 | panel->Show(); 186 | return B_OK; 187 | } 188 | } 189 | } 190 | } 191 | } 192 | } 193 | } 194 | return BOutlineListView::Invoke(msg); 195 | } 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptView.h: -------------------------------------------------------------------------------- 1 | /* 2 | ScriptView.h 3 | 4 | Copyright 1997 Be Incorporated, All Rights Reserved. 5 | Copyright 1999, Be Incorporated. All Rights Reserved. 6 | This file may be used under the terms of the Be Sample Code License. 7 | */ 8 | 9 | #ifndef SCRIPT_VIEW_H 10 | #define SCRIPT_VIEW_H 11 | 12 | #include 13 | 14 | class ScriptView : public BOutlineListView 15 | { 16 | public: 17 | ScriptView(BRect frame, const char *name); 18 | 19 | virtual status_t FillList(); 20 | virtual status_t Invoke(BMessage *msg = NULL); 21 | }; 22 | 23 | #endif //SCRIPT_VIEW_H 24 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptWindow.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ScriptWindow.cpp 3 | 4 | Copyright 1995 Be Incorporated, All Rights Reserved. 5 | Copyright 1999, Be Incorporated. All Rights Reserved. 6 | This file may be used under the terms of the Be Sample Code License. 7 | */ 8 | 9 | #include 10 | #include 11 | #include "ScriptWindow.h" 12 | #include "ScriptView.h" 13 | 14 | ScriptWindow::ScriptWindow(BRect frame) 15 | : BWindow(frame, "Scripting Explorer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | 16 | B_QUIT_ON_WINDOW_CLOSE) 17 | { 18 | ScriptView *scriptView; 19 | 20 | BRect r(Bounds()); 21 | 22 | r.right -= B_V_SCROLL_BAR_WIDTH; 23 | scriptView = new ScriptView(r, "ScriptView"); 24 | 25 | BScrollView *scrollView = new BScrollView("scrollView", scriptView, 26 | B_FOLLOW_ALL, 0, false, true); 27 | AddChild(scrollView); 28 | 29 | scriptView->FillList(); 30 | 31 | // Items in the list will all have the same height, so we can assume that 32 | // item height * item count is OK. 33 | BListItem *item = scriptView->ItemAt(0L); 34 | if (item) 35 | { 36 | BRect itemFrame = scriptView->ItemFrame(0L); 37 | int32 count = scriptView->CountItems(); 38 | count = MAX(count, 15); 39 | ResizeTo(Bounds().IntegerWidth(),itemFrame.IntegerHeight() * count); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ScriptWindow.h 3 | 4 | Copyright 1997 Be Incorporated, All Rights Reserved. 5 | Copyright 1999, Be Incorporated. All Rights Reserved. 6 | This file may be used under the terms of the Be Sample Code License. 7 | */ 8 | 9 | #ifndef SCRIPT_WINDOW_H 10 | #define SCRIPT_WINDOW_H 11 | 12 | #include 13 | 14 | class ScriptWindow : public BWindow 15 | { 16 | public: 17 | ScriptWindow(BRect frame); 18 | }; 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptWorld.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ScriptWorld.cpp 3 | 4 | Copyright 1999, Be Incorporated. All Rights Reserved. 5 | This file may be used under the terms of the Be Sample Code License. 6 | */ 7 | 8 | #include 9 | 10 | #include "ScriptWindow.h" 11 | 12 | class ScriptApplication : public BApplication 13 | { 14 | public: 15 | ScriptApplication(); 16 | }; 17 | 18 | 19 | ScriptApplication::ScriptApplication() 20 | : BApplication("application/x-vnd.dw-ScriptingExplorer") 21 | { 22 | ScriptWindow *aWindow = new ScriptWindow(BRect(100, 80, 300, 280)); 23 | aWindow->Show(); 24 | } 25 | 26 | 27 | int 28 | main(void) 29 | { 30 | ScriptApplication().Run(); 31 | return 0; 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptWorld.pld: -------------------------------------------------------------------------------- 1 | NAME=ScriptWorld 2 | TARGETNAME=ScriptWorld 3 | PLATFORM=HaikuGCC4 4 | SCM=hg 5 | GROUP=Sources 6 | EXPANDGROUP=yes 7 | SOURCEFILE=PropDump.cpp 8 | DEPENDENCY=/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/PropDump.cpp|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/PropDump.h 9 | SOURCEFILE=ScriptView.cpp 10 | DEPENDENCY=/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptView.cpp|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptView.h|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/PropDump.h|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/SendPanel.h 11 | SOURCEFILE=ScriptWindow.cpp 12 | DEPENDENCY=/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptWindow.cpp|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptWindow.h|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptView.h 13 | SOURCEFILE=ScriptWorld.cpp 14 | DEPENDENCY=/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptWorld.cpp|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptWindow.h|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/ScriptWorld.h 15 | SOURCEFILE=SendPanel.cpp 16 | DEPENDENCY=/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/SendPanel.cpp|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/PropDump.h|/boot/home/Desktop/sample-code/application_kit/Scripter/ScriptWorld/SendPanel.h 17 | SOURCEFILE=ScriptWorld.rsrc 18 | SYSTEMINCLUDE=/boot/develop/headers/be 19 | SYSTEMINCLUDE=/boot/develop/headers/cpp 20 | SYSTEMINCLUDE=/boot/develop/headers/posix 21 | SYSTEMINCLUDE=/boot/develop/lib 22 | SYSTEMINCLUDE=/boot/beos/system/lib 23 | LIBRARY=/boot/develop/lib/x86/libbe.so 24 | LIBRARY=/boot/develop/lib/x86/libsupc++.so 25 | RUNARGS= 26 | CCDEBUG=yes 27 | CCPROFILE=no 28 | CCOPSIZE=no 29 | CCOPLEVEL=3 30 | CCTARGETTYPE=0 31 | CCEXTRA=-Woverloaded-virtual -funsigned-bitfields -Wwrite-strings 32 | LDEXTRA= 33 | -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/ScriptWorld.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/Scripting Explorer/ScriptWorld.rsrc -------------------------------------------------------------------------------- /volume2/Sources/Scripting Explorer/SendPanel.h: -------------------------------------------------------------------------------- 1 | //****************************************************************************** 2 | // 3 | // File: SendPanel.h 4 | // 5 | // Written by: Douglas Wright 6 | // 7 | //****************************************************************************** 8 | 9 | /* 10 | Copyright 1999, Be Incorporated. All Rights Reserved. 11 | This file may be used under the terms of the Be Sample Code License. 12 | */ 13 | 14 | #ifndef _SEND_PANEL_H 15 | #define _SEND_PANEL_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | class SendView; 26 | 27 | class SendPanel : public BWindow 28 | { 29 | 30 | public: 31 | SendPanel(BMessenger *msgr, BRect *frame = NULL); 32 | virtual ~SendPanel(); 33 | }; 34 | 35 | 36 | class SpecView; 37 | class BTextControl; 38 | class BCheckBox; 39 | class BMenuField; 40 | 41 | class SendView : public BView 42 | { 43 | public: 44 | SendView(BRect rect); 45 | virtual ~SendView(); 46 | 47 | virtual void AttachedToWindow(); 48 | virtual void MessageReceived(BMessage *msg); 49 | 50 | void BuildMessage(BMessage *msg) const; 51 | void SetMessenger(BMessenger *msgr); 52 | void FrameResized(float w, float h); 53 | 54 | private: 55 | 56 | void AddMessageTypesToMenu(); 57 | 58 | void AddSpecView(); 59 | void RemoveSpecView(); 60 | void DoSendMessage(); 61 | 62 | status_t GetTCInt32(const BTextControl* pCtrl, int32* dest) const; 63 | status_t GetTCUint32(const BTextControl* pCtrl, uint32* dest) const; 64 | status_t GetTCInt32Range(const BTextControl* pCtrl, int32* begin, int32* end) const; 65 | 66 | BList specViewList; 67 | BBox *fSpecBox; 68 | BMenu *fMessageTypeMenu; 69 | BMessenger *fMessenger; 70 | BTextView *fText; 71 | BButton *fAdd, 72 | *fRemove, 73 | *fSend; 74 | float fTextBoxHeight; 75 | }; 76 | 77 | class SpecView : public BView 78 | { 79 | public: 80 | SpecView(BRect); 81 | virtual ~SpecView(); 82 | 83 | virtual void AttachedToWindow(); 84 | 85 | BMenuField *fMenu; 86 | BTextControl *fText1; 87 | BTextControl *fText2; 88 | 89 | }; 90 | 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /volume2/Sources/SetMime.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int 5 | main(void) 6 | { 7 | BMimeType mime("application/x-person"); 8 | BMessage attrMsg; 9 | 10 | // We get the existing information for Person files because otherwise 11 | // we will replace it with the two measly attributes that we have below. 12 | // We want to add to the existing attributes for Person files, not 13 | // replace them. 14 | mime.GetAttrInfo(&attrMsg); 15 | 16 | // Each of these fields needs to be added to the message for the 17 | // custom attribute to be useful. 18 | attrMsg.AddString("attr:public_name", "First Name"); 19 | attrMsg.AddString("attr:name", "META:firstname"); 20 | attrMsg.AddInt32("attr:type", B_STRING_TYPE); 21 | attrMsg.AddBool("attr:viewable", true); 22 | attrMsg.AddBool("attr:editable", true); 23 | 24 | // These three fields are not documented in the Be Book, but are used by 25 | // Tracker to determine how the information is displayed in a Tracker 26 | // window. 27 | attrMsg.AddInt32("attr:width", 120); 28 | attrMsg.AddInt32("attr:alignment", B_ALIGN_LEFT); 29 | attrMsg.AddBool("attr:extra", false); 30 | 31 | attrMsg.AddString("attr:public_name", "Last Name"); 32 | attrMsg.AddString("attr:name", "META:lastname"); 33 | attrMsg.AddInt32("attr:type", B_STRING_TYPE); 34 | attrMsg.AddBool("attr:viewable", true); 35 | attrMsg.AddBool("attr:editable", true); 36 | attrMsg.AddInt32("attr:width", 120); 37 | attrMsg.AddInt32("attr:alignment", B_ALIGN_LEFT); 38 | attrMsg.AddBool("attr:extra", false); 39 | 40 | mime.SetAttrInfo(&attrMsg); 41 | } 42 | -------------------------------------------------------------------------------- /volume2/Sources/TrackerAddon.cpp: -------------------------------------------------------------------------------- 1 | #include "TrackerAddon.h" 2 | 3 | #include 4 | #include 5 | 6 | void 7 | process_refs(entry_ref dir_ref, BMessage *msg, void *data) 8 | { 9 | BString out("Entries sent to Tracker addon:\n\n"); 10 | 11 | entry_ref ref; 12 | int32 i = 0; 13 | while (msg->FindRef("refs", i++, &ref) == B_OK) 14 | out << ref.name << "\n"; 15 | 16 | BAlert *alert = new BAlert("SampleAddon", out.String(), "OK"); 17 | alert->Go(); 18 | } 19 | 20 | -------------------------------------------------------------------------------- /volume2/Sources/TrackerAddon.h: -------------------------------------------------------------------------------- 1 | #ifndef TRACKER_ADDON_H 2 | #define TRACKER_ADDON_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern "C" 9 | { 10 | void process_refs(entry_ref dir_ref, BMessage *msg, void *data); 11 | } 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /volume2/Sources/TrackerAddon.pld: -------------------------------------------------------------------------------- 1 | NAME=TrackerAddon 2 | TARGETNAME=TrackerAddon 3 | PLATFORM=HaikuGCC4 4 | SCM=hg 5 | GROUP=Source Files 6 | EXPANDGROUP=yes 7 | SOURCEFILE=TrackerAddon.cpp 8 | DEPENDENCY=/boot/home/projects/TrackerAddon/TrackerAddon.h 9 | SOURCEFILE=TrackerAddon.rsrc 10 | SYSTEMINCLUDE=/boot/develop/headers/be 11 | SYSTEMINCLUDE=/boot/develop/headers/cpp 12 | SYSTEMINCLUDE=/boot/develop/headers/posix 13 | SYSTEMINCLUDE=/boot/home/config/include 14 | LIBRARY=/boot/develop/lib/x86/libroot.so 15 | LIBRARY=/boot/develop/lib/x86/libbe.so 16 | LIBRARY=/boot/develop/lib/x86/libsupc++.so 17 | LIBRARY=/boot/system/lib/libsupc++.so 18 | RUNARGS= 19 | CCDEBUG=no 20 | CCPROFILE=no 21 | CCOPSIZE=no 22 | CCOPLEVEL=0 23 | CCTARGETTYPE=1 24 | CCEXTRA= 25 | LDEXTRA= 26 | -------------------------------------------------------------------------------- /volume2/Sources/TrackerAddon.rsrc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TrackerAddon.rsrc -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/00changelog.i: -------------------------------------------------------------------------------- 1 |  dummy changelog to prevent using the old repo layout -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/cache/branchheads: -------------------------------------------------------------------------------- 1 | 01bcd41f7eb7dcc4b5d0185a62477511bb1555d0 0 2 | 01bcd41f7eb7dcc4b5d0185a62477511bb1555d0 default 3 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/dirstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/dirstate -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/last-message.txt: -------------------------------------------------------------------------------- 1 | Remove some disabled code 2 | 3 | HG: 4 | HG: All lines starting with HG: will be ignored. 5 | HG: ---------------------------------------------------- 6 | HG: M MainWindow.cpp 7 | HG: M TranslatorDemo.pld 8 | HG: ? (Objects.TranslatorDemo)/App.o 9 | HG: ? (Objects.TranslatorDemo)/BitmapView.o 10 | HG: ? (Objects.TranslatorDemo)/BitmapWindow.o 11 | HG: ? (Objects.TranslatorDemo)/MainWindow.o 12 | HG: ? TranslatorDemo 13 | HG: -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/requires: -------------------------------------------------------------------------------- 1 | revlogv1 2 | store 3 | fncache 4 | dotencode 5 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/00changelog.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/00changelog.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/00manifest.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/00manifest.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_app.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_app.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_app.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_app.h.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_view.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_view.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_view.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_view.h.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_window.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_window.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_window.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_bitmap_window.h.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_main_window.cpp.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_main_window.cpp.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_main_window.h.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_main_window.h.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/data/_translator_demo.pld.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/store/data/_translator_demo.pld.i -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/fncache: -------------------------------------------------------------------------------- 1 | data/TranslatorDemo.pld.i 2 | data/App.cpp.i 3 | data/BitmapView.cpp.i 4 | data/BitmapWindow.cpp.i 5 | data/MainWindow.h.i 6 | data/App.h.i 7 | data/BitmapWindow.h.i 8 | data/MainWindow.cpp.i 9 | data/BitmapView.h.i 10 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/store/undo: -------------------------------------------------------------------------------- 1 | data/MainWindow.cpp.i1797 2 | data/TranslatorDemo.pld.i420 3 | 00manifest.i368 4 | 00changelog.i221 5 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/undo.branch: -------------------------------------------------------------------------------- 1 | default -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/undo.desc: -------------------------------------------------------------------------------- 1 | 1 2 | commit 3 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/.hg/undo.dirstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/Sources/TranslatorDemo/.hg/undo.dirstate -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/App.cpp: -------------------------------------------------------------------------------- 1 | #include "App.h" 2 | #include "MainWindow.h" 3 | 4 | 5 | App::App(void) 6 | : BApplication("application/x-vnd.dw-TranslatorDemo") 7 | { 8 | MainWindow *mainwin = new MainWindow(); 9 | mainwin->Show(); 10 | } 11 | 12 | 13 | int 14 | main(void) 15 | { 16 | App *app = new App(); 17 | app->Run(); 18 | delete app; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/App.h: -------------------------------------------------------------------------------- 1 | #ifndef APP_H 2 | #define APP_H 3 | 4 | #include 5 | 6 | class App : public BApplication 7 | { 8 | public: 9 | App(void); 10 | }; 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/BitmapView.h: -------------------------------------------------------------------------------- 1 | /* 2 | BitmapView.cpp: A simple picture display control with some nice extras 3 | Written by DarkWyrm , Copyright 2007 4 | Released under the MIT license. 5 | */ 6 | #ifndef BMPVIEW_H 7 | #define BMPVIEW_H 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | enum 17 | { 18 | M_BITMAP_ADDED='mbma', 19 | M_BITMAP_REMOVED='mbmr' 20 | }; 21 | 22 | class BitmapView : public BView, public BInvoker 23 | { 24 | public: 25 | BitmapView(const BRect &frame, const char *name, 26 | BMessage *mod, BBitmap *bitmap, 27 | border_style = B_PLAIN_BORDER, 28 | const int32 &resize = B_FOLLOW_LEFT | 29 | B_FOLLOW_TOP, 30 | const int32 &flags = B_WILL_DRAW); 31 | ~BitmapView(void); 32 | 33 | virtual void AttachedToWindow(void); 34 | virtual void Draw(BRect rect); 35 | virtual void MessageReceived(BMessage *msg); 36 | virtual void MouseDown(BPoint pt); 37 | 38 | virtual void SetBitmap(BBitmap *bitmap); 39 | BBitmap * GetBitmap(void) const; 40 | 41 | virtual void SetEnabled(bool value); 42 | bool IsEnabled(void) const; 43 | 44 | virtual void SetStyle(border_style style); 45 | border_style Style(void) const; 46 | 47 | void SetFixedSize(bool isfixed); 48 | bool IsFixedSize(void) const; 49 | 50 | virtual void SetAcceptDrops(bool accept); 51 | bool AcceptsDrops(void) const; 52 | 53 | virtual void SetAcceptPaste(bool accept); 54 | bool AcceptsPaste(void) const; 55 | 56 | virtual void SetConstrainDrops(bool value); 57 | bool ConstrainsDrops(void) const; 58 | 59 | virtual void SetMaxBitmapSize(const float &width, const float &height); 60 | void MaxBitmapSize(float *width, float *height) const; 61 | 62 | void SetBitmapRemovable(bool isremovable); 63 | bool IsBitmapRemovable(void) const; 64 | 65 | void RemoveBitmap(void); 66 | void PasteBitmap(void); 67 | 68 | virtual void FrameResized(float width, float height); 69 | 70 | private: 71 | void CalculateBitmapRect(void); 72 | BRect ScaleRectToFit(const BRect &from, const BRect &to); 73 | void ConstrainBitmap(void); 74 | 75 | bool ClipboardHasBitmap(void); 76 | BBitmap * BitmapFromClipboard(void); 77 | 78 | float fNoPhotoWidths[4]; 79 | BPoint fNoPhotoOffsets[4]; 80 | 81 | BBitmap *fBitmap; 82 | BRect fBitmapRect; 83 | bool fEnabled; 84 | border_style fBorderStyle; 85 | 86 | bool fFixedSize, 87 | fAcceptDrops, 88 | fAcceptPaste, 89 | fConstrainDrops; 90 | 91 | float fMaxWidth, 92 | fMaxHeight; 93 | 94 | bool fRemovableBitmap; 95 | BPopUpMenu *fPopUpMenu; 96 | uint32 fMouseButtons; 97 | 98 | BMenuItem *fPasteItem; 99 | BMenuItem *fRemoveItem; 100 | }; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/BitmapWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "BitmapWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "BitmapView.h" 8 | 9 | BitmapWindow::BitmapWindow(const entry_ref &ref) 10 | : BWindow(BRect(100, 100, 500, 400), ref.name, B_DOCUMENT_WINDOW, B_ASYNCHRONOUS_CONTROLS) 11 | { 12 | BBitmap *image = BTranslationUtils::GetBitmap(&ref); 13 | fView = new BitmapView(Bounds(), "bitmapview", new BMessage, image, 14 | B_NO_BORDER, B_FOLLOW_ALL); 15 | fView->SetFixedSize(false); 16 | AddChild(fView); 17 | 18 | BRect screen(BScreen().Frame()); 19 | if (image) 20 | { 21 | BRect size(image->Bounds()); 22 | if (size.Width() > (screen.Width() * .8)) 23 | { 24 | float multiplier = (screen.Width() * .8) / size.Width(); 25 | size.right = size.Width() * multiplier; 26 | size.bottom = size.Height() * multiplier; 27 | } 28 | 29 | ResizeTo(size.Width(), size.Height()); 30 | } 31 | 32 | BRect frame(Frame()); 33 | MoveTo( (screen.Width() - frame.Width()) / 2.0, 34 | (screen.Height() - frame.Height()) / 2.0); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/BitmapWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef BITMAPWINDOW_H 2 | #define BITMAPWINDOW_H 3 | 4 | #include 5 | #include 6 | 7 | class BitmapView; 8 | 9 | class BitmapWindow : public BWindow 10 | { 11 | public: 12 | BitmapWindow(const entry_ref &ref); 13 | 14 | private: 15 | BitmapView *fView; 16 | }; 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/MainWindow.cpp: -------------------------------------------------------------------------------- 1 | #include "MainWindow.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "BitmapWindow.h" 14 | 15 | enum 16 | { 17 | M_SHOW_PANEL = 'shpl' 18 | }; 19 | 20 | 21 | MainWindow::MainWindow(void) 22 | : BWindow(BRect(100, 100, 500, 400), "TranslatorDemo", B_TITLED_WINDOW, 23 | B_ASYNCHRONOUS_CONTROLS) 24 | { 25 | BRect r(Bounds()); 26 | r.bottom = 20; 27 | fMenuBar = new BMenuBar(r,"menubar"); 28 | AddChild(fMenuBar); 29 | 30 | BMenu *menu = new BMenu("File"); 31 | fMenuBar->AddItem(menu); 32 | 33 | menu->AddItem(new BMenuItem("Open", new BMessage(M_SHOW_PANEL), 'O')); 34 | 35 | BView *back = new BView(Bounds(), "background", B_FOLLOW_ALL, B_WILL_DRAW); 36 | back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 37 | AddChild(back); 38 | 39 | BRect rect, textRect; 40 | rect = Bounds().InsetByCopy(10.0, 10.0); 41 | rect.top += 20; 42 | rect.right -= B_V_SCROLL_BAR_WIDTH; 43 | 44 | textRect = rect.OffsetToCopy(0.0, 0.0); 45 | textRect.InsetBy(5.0, 5.0); 46 | fTextView = new BTextView(rect, "textview", textRect, B_FOLLOW_ALL); 47 | fTextView->MakeEditable(false); 48 | fTextView->SetViewColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), 49 | B_LIGHTEN_1_TINT)); 50 | 51 | BScrollView *scrollView = new BScrollView("scrollview", fTextView, 52 | B_FOLLOW_ALL, 0, false, true); 53 | back->AddChild(scrollView); 54 | 55 | PopulateTextView(); 56 | 57 | BMessenger messenger(NULL, this); 58 | fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL, 0, false); 59 | } 60 | 61 | 62 | MainWindow::~MainWindow(void) 63 | { 64 | delete fOpenPanel; 65 | } 66 | 67 | 68 | void 69 | MainWindow::MessageReceived(BMessage *msg) 70 | { 71 | switch (msg->what) 72 | { 73 | case M_SHOW_PANEL: 74 | { 75 | fOpenPanel->Show(); 76 | break; 77 | } 78 | case B_REFS_RECEIVED: 79 | { 80 | int32 i = 0; 81 | entry_ref ref; 82 | while (msg->FindRef("refs", i, &ref) == B_OK) 83 | { 84 | BitmapWindow *win = new BitmapWindow(ref); 85 | win->Show(); 86 | i++; 87 | } 88 | break; 89 | } 90 | default: 91 | { 92 | BWindow::MessageReceived(msg); 93 | break; 94 | } 95 | } 96 | } 97 | 98 | 99 | bool 100 | MainWindow::QuitRequested(void) 101 | { 102 | be_app->PostMessage(B_QUIT_REQUESTED); 103 | return true; 104 | } 105 | 106 | 107 | void 108 | MainWindow::PopulateTextView(void) 109 | { 110 | BString out; 111 | out << "This app demonstrates the use of the Translation Kit. Open an " 112 | "image file using the File menu.\n\n" 113 | "Translator Information:\n-------------------------------------\n\n"; 114 | 115 | // This gets a pointer to the global translator roster which already has 116 | // the default translators already loaded. The pointer may not be deleted. 117 | BTranslatorRoster *roster = BTranslatorRoster::Default(); 118 | 119 | // This call is very important if you want to find out more about the 120 | // Kit's capabilities. A translator_id is a unique handle for each 121 | // translator. Using it, we can find out specific information about each 122 | // one. 123 | int32 translatorCount; 124 | translator_id *translators; 125 | roster->GetAllTranslators(&translators, &translatorCount); 126 | 127 | for (int32 i = 0; i < translatorCount; i++) 128 | { 129 | const char *name, *info; 130 | int32 version; 131 | roster->GetTranslatorInfo(translators[i], &name, &info, &version); 132 | 133 | out << name << " version " << float(version / 100.0) << "\n\n"; 134 | 135 | out << "Supported Input Formats:\n"; 136 | 137 | const translation_format *inFormats; 138 | int32 inCount; 139 | roster->GetInputFormats(translators[i], &inFormats, &inCount); 140 | for (int32 j = 0; j < inCount; j++) 141 | { 142 | translation_format format = inFormats[j]; 143 | out << "\tMIME type: " << format.MIME << "\n"; 144 | } 145 | 146 | 147 | const translation_format *outFormats; 148 | int32 outCount; 149 | roster->GetOutputFormats(translators[i], &outFormats, &outCount); 150 | 151 | out << "\n"; 152 | } 153 | 154 | delete [] translators; 155 | 156 | fTextView->SetText(out.String()); 157 | } 158 | 159 | 160 | void 161 | MainWindow::FrameResized(float w, float h) 162 | { 163 | BRect textRect = fTextView->Bounds().InsetByCopy(5.0, 5.0); 164 | fTextView->SetTextRect(textRect); 165 | } 166 | 167 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/MainWindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class MainWindow : public BWindow 10 | { 11 | public: 12 | MainWindow(void); 13 | ~MainWindow(void); 14 | void MessageReceived(BMessage *msg); 15 | bool QuitRequested(void); 16 | void FrameResized(float w, float h); 17 | 18 | private: 19 | void PopulateTextView(void); 20 | 21 | BMenuBar *fMenuBar; 22 | BTextView *fTextView; 23 | 24 | BFilePanel *fOpenPanel; 25 | }; 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /volume2/Sources/TranslatorDemo/TranslatorDemo.pld: -------------------------------------------------------------------------------- 1 | NAME=TranslatorDemo 2 | TARGETNAME=TranslatorDemo 3 | PLATFORM=R5 4 | SCM=hg 5 | GROUP=Source Files 6 | EXPANDGROUP=yes 7 | SOURCEFILE=App.cpp 8 | DEPENDENCY=/boot/home/projects/TranslatorDemo/App.h|/boot/home/projects/TranslatorDemo/MainWindow.h 9 | SOURCEFILE=BitmapView.cpp 10 | DEPENDENCY=/boot/home/Desktop/TranslatorDemo/BitmapView.h 11 | SOURCEFILE=BitmapWindow.cpp 12 | DEPENDENCY=/boot/home/Desktop/TranslatorDemo/BitmapWindow.h|/boot/home/Desktop/TranslatorDemo/BitmapView.h 13 | SOURCEFILE=MainWindow.cpp 14 | DEPENDENCY=/boot/home/projects/TranslatorDemo/MainWindow.h 15 | SYSTEMINCLUDE=/boot/develop/headers/be 16 | SYSTEMINCLUDE=/boot/develop/headers/cpp 17 | SYSTEMINCLUDE=/boot/develop/headers/posix 18 | SYSTEMINCLUDE=/boot/home/config/include 19 | LIBRARY=/boot/develop/lib/x86/libroot.so 20 | LIBRARY=/boot/develop/lib/x86/libbe.so 21 | LIBRARY=/boot/develop/lib/x86/libtracker.so 22 | LIBRARY=/boot/develop/lib/x86/libtranslation.so 23 | LIBRARY=/boot/develop/lib/x86/libsupc++.so 24 | RUNARGS= 25 | CCDEBUG=no 26 | CCPROFILE=no 27 | CCOPSIZE=no 28 | CCOPLEVEL=0 29 | CCTARGETTYPE=0 30 | CCEXTRA= 31 | LDEXTRA= 32 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 39815 5 | svn+ssh://darkwyrm@svn.haiku-os.org/srv/svn/repos/haiku/haiku/trunk/src/apps/overlayimage 6 | svn+ssh://darkwyrm@svn.haiku-os.org/srv/svn/repos/haiku 7 | 8 | 9 | 10 | 2010-07-21T18:22:34.793672Z 11 | 37668 12 | humdinger 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | a95241bf-73f2-0310-859d-f6bbb57e9c96 28 | 29 | OverlayWindow.h 30 | file 31 | 32 | 33 | 34 | 35 | 2010-11-24T21:17:02.000000Z 36 | c7b6893714ae128c6041b483793be3e4 37 | 2010-06-30T18:04:25.038098Z 38 | 37322 39 | humdinger 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 581 62 | 63 | OverlayView.h 64 | file 65 | 66 | 67 | 68 | 69 | 2010-11-24T21:17:02.000000Z 70 | c11ba88d93f87aac126ace26fbff8677 71 | 2010-06-30T18:04:25.038098Z 72 | 37322 73 | humdinger 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 1110 96 | 97 | OverlayApp.cpp 98 | file 99 | 100 | 101 | 102 | 103 | 2010-11-24T21:17:02.000000Z 104 | 99629783713a95e06df1865316428df2 105 | 2010-07-10T11:08:26.696772Z 106 | 37455 107 | mmadia 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 648 130 | 131 | OverlayImage.rdef 132 | file 133 | 134 | 135 | 136 | 137 | 2010-11-24T21:17:02.000000Z 138 | 3879ee0e6752c3b81ed2533a70eb4c8c 139 | 2010-06-22T17:58:12.163724Z 140 | 37222 141 | humdinger 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 1342 164 | 165 | Jamfile 166 | file 167 | 168 | 169 | 170 | 171 | 2010-11-24T21:17:02.000000Z 172 | f8d2ce7ba0a3501814d1afa98a877e1e 173 | 2010-07-10T11:08:26.696772Z 174 | 37455 175 | mmadia 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 287 198 | 199 | OverlayApp.h 200 | file 201 | 202 | 203 | 204 | 205 | 2010-11-24T21:17:02.000000Z 206 | 5774d98b008cd48a2c431ca2e8d25a83 207 | 2010-07-10T11:08:26.696772Z 208 | 37455 209 | mmadia 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 585 232 | 233 | OverlayWindow.cpp 234 | file 235 | 236 | 237 | 238 | 239 | 2010-11-24T21:17:02.000000Z 240 | be4dcdd98e2972c73ca578071999c14f 241 | 2010-06-30T18:04:25.038098Z 242 | 37322 243 | humdinger 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 1053 266 | 267 | OverlayView.cpp 268 | file 269 | 270 | 271 | 272 | 273 | 2010-11-24T21:17:02.000000Z 274 | 28af91df0cf6b43b73662b5d6e767ad8 275 | 2010-07-21T18:22:34.793672Z 276 | 37668 277 | humdinger 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 3473 300 | 301 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/Jamfile.svn-base: -------------------------------------------------------------------------------- 1 | SubDir HAIKU_TOP src apps overlayimage ; 2 | 3 | Application OverlayImage : 4 | OverlayApp.cpp 5 | OverlayView.cpp 6 | OverlayWindow.cpp 7 | 8 | : be libtranslation.so $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS) 9 | : OverlayImage.rdef 10 | ; 11 | 12 | DoCatalogs OverlayImage : 13 | x-vnd.Haiku-OverlayImage 14 | : 15 | OverlayWindow.cpp 16 | ; 17 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayApp.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #include "OverlayApp.h" 15 | #include "OverlayWindow.h" 16 | 17 | 18 | OverlayApp::OverlayApp() 19 | : BApplication("application/x-vnd.Haiku-OverlayImage") 20 | { 21 | OverlayWindow *theWindow = new OverlayWindow(); 22 | theWindow->Show(); 23 | } 24 | 25 | 26 | int 27 | main() 28 | { 29 | OverlayApp theApp; 30 | theApp.Run(); 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayApp.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #ifndef OVERLAY_APP_H 15 | #define OVERLAY_APP_H 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | class OverlayApp : public BApplication { 23 | public: 24 | OverlayApp(); 25 | }; 26 | 27 | #endif // OVERLAY_APP_H 28 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayImage.rdef.svn-base: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Haiku-OverlayImage"; 2 | 3 | resource app_flags B_MULTIPLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 9, 8 | minor = 0, 9 | 10 | /* 0 = development 1 = alpha 2 = beta 11 | 3 = gamma 4 = golden master 5 = final */ 12 | variety = 5, 13 | 14 | internal = 0, 15 | 16 | short_info = "Replicantable Image Viewer", 17 | long_info = "View an image and put it as replicant e.g. on the Desktop" 18 | }; 19 | 20 | resource vector_icon { 21 | $"6E6369660502000603399E0F3D9C0ABF82B23B84A84B88504870C900F0D733BC" 22 | $"FFFEEAFFE0F154050105FF04019203FF00A7050606AE0B284033C3AE2A44BE00" 23 | $"C5EC4454543C4430C5A6BACF3E2E3C28020ABB1EBB84BB1EBB84BB1EBB842E3A" 24 | $"3038B784BE6B2C40B68DBF7130413A423243404044404242C222BEF54C3E4E40" 25 | $"C43EBEAA4E3CC3EFBE67C6B9BDE84A36C673BC10C0FDBB773A3ABF31BC71363C" 26 | $"323C343CB8EDBDDB020248404A404640484444444C440202C65EBE74C6D2BE67" 27 | $"C5EDBE81C653BF0DC5C5BEDAC6DEBF400A04304A30504250424A080A03010002" 28 | $"4014CABE1A903E2F65402966C834CE48FF1D0A01010012BC3AE4C02527402527" 29 | $"BC3AE443BD604C697101178400040A00010002BC3FE0C029F24029F2BC3FE043" 30 | $"99B24C6BC80A0403010203023F66E5B3B70FB829F03FF40743681746AB1E0A02" 31 | $"0104023CF34B3F5F71BFB7D13CAD2B4B19BAC8C4530A010104123CF34B3F5F71" 32 | $"BFB7D13CAD2B4B19BAC8C45301178200040A02010402BF34E93E641CBE641CBF" 33 | $"34E94CFF874AC2190A01010412BF34E93E641CBE641CBF34E94CFF874AC21901" 34 | $"17820004" 35 | }; 36 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayView.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #include "OverlayView.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #undef B_TRANSLATE_CONTEXT 23 | #define B_TRANSLATE_CONTEXT "Main window" 24 | 25 | const float kDraggerSize = 7; 26 | 27 | 28 | OverlayView::OverlayView(BRect frame) 29 | : 30 | BView(frame, "OverlayImage", B_FOLLOW_NONE, B_WILL_DRAW) 31 | { 32 | fBitmap = NULL; 33 | fReplicated = false; 34 | 35 | frame.left = frame.right - kDraggerSize; 36 | frame.top = frame.bottom - kDraggerSize; 37 | BDragger *dragger = new BDragger(frame, this, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); 38 | AddChild(dragger); 39 | 40 | SetViewColor(B_TRANSPARENT_COLOR); 41 | 42 | fText = new BTextView(Bounds(), "bgView", Bounds(), B_FOLLOW_ALL, B_WILL_DRAW); 43 | fText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 44 | AddChild(fText); 45 | BString text; 46 | text << B_TRANSLATE( 47 | "Enable \"Show replicants\" in Deskbar.\n" 48 | "Drag & drop an image.\n" 49 | "Drag the replicant to the Desktop."); 50 | fText->SetText(text); 51 | fText->SetAlignment(B_ALIGN_CENTER); 52 | fText->MakeSelectable(false); 53 | fText->MoveBy(0, (Bounds().bottom - fText->TextRect().bottom) / 2); 54 | } 55 | 56 | 57 | OverlayView::OverlayView(BMessage *archive) 58 | : 59 | BView(archive) 60 | { 61 | fReplicated = true; 62 | fBitmap = new BBitmap(archive); 63 | } 64 | 65 | 66 | OverlayView::~OverlayView() 67 | { 68 | delete fBitmap; 69 | } 70 | 71 | 72 | void 73 | OverlayView::Draw(BRect) 74 | { 75 | SetDrawingMode(B_OP_ALPHA); 76 | SetViewColor(B_TRANSPARENT_COLOR); 77 | 78 | if (fBitmap) 79 | DrawBitmap(fBitmap, B_ORIGIN); 80 | } 81 | 82 | 83 | void 84 | OverlayView::MessageReceived(BMessage *msg) 85 | { 86 | switch (msg->what) { 87 | case B_SIMPLE_DATA: 88 | { 89 | if (fReplicated) 90 | break; 91 | 92 | entry_ref ref; 93 | msg->FindRef("refs", &ref); 94 | BEntry entry(&ref); 95 | BPath path(&entry); 96 | 97 | delete fBitmap; 98 | fBitmap = BTranslationUtils::GetBitmap(path.Path()); 99 | 100 | if (fBitmap != NULL) { 101 | if (fText != NULL) { 102 | RemoveChild(fText); 103 | fText = NULL; 104 | } 105 | 106 | BRect rect = fBitmap->Bounds(); 107 | if (!fReplicated) { 108 | Window()->ResizeTo(rect.right, rect.bottom); 109 | Window()->Activate(true); 110 | } 111 | ResizeTo(rect.right, rect.bottom); 112 | Invalidate(); 113 | } 114 | break; 115 | } 116 | case B_ABOUT_REQUESTED: 117 | OverlayAboutRequested(); 118 | break; 119 | 120 | default: 121 | BView::MessageReceived(msg); 122 | break; 123 | } 124 | } 125 | 126 | 127 | BArchivable *OverlayView::Instantiate(BMessage *data) 128 | { 129 | return new OverlayView(data); 130 | } 131 | 132 | 133 | status_t 134 | OverlayView::Archive(BMessage *archive, bool deep) const 135 | { 136 | BView::Archive(archive, deep); 137 | 138 | archive->AddString("add_on", "application/x-vnd.Haiku-OverlayImage"); 139 | archive->AddString("class", "OverlayImage"); 140 | 141 | if (fBitmap) { 142 | fBitmap->Lock(); 143 | fBitmap->Archive(archive); 144 | fBitmap->Unlock(); 145 | } 146 | //archive->PrintToStream(); 147 | 148 | return B_OK; 149 | } 150 | 151 | 152 | void 153 | OverlayView::OverlayAboutRequested() 154 | { 155 | BAlert *alert = new BAlert("about", 156 | "OverlayImage\n" 157 | "Copyright 1999-2010\n\n\t" 158 | "originally by Seth Flaxman\n\t" 159 | "modified by Hartmuth Reh\n\t" 160 | "further modified by Humdinger\n", 161 | "OK"); 162 | 163 | BTextView *view = alert->TextView(); 164 | BFont font; 165 | view->SetStylable(true); 166 | view->GetFont(&font); 167 | font.SetSize(font.Size() + 7.0f); 168 | font.SetFace(B_BOLD_FACE); 169 | view->SetFontAndColor(0, 12, &font); 170 | 171 | alert->Go(); 172 | } 173 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayView.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #ifndef OVERLAY_VIEW_H 15 | #define OVERLAY_VIEW_H 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | class _EXPORT OverlayView; 30 | 31 | class OverlayView : public BView { 32 | public: 33 | OverlayView(BRect frame); 34 | OverlayView(BMessage *data); 35 | ~OverlayView(); 36 | virtual void Draw(BRect); 37 | virtual void MessageReceived(BMessage *msg); 38 | static BArchivable *Instantiate(BMessage *archive); 39 | virtual status_t Archive(BMessage *data, bool deep = true) const; 40 | void OverlayAboutRequested(); 41 | 42 | private: 43 | BBitmap *fBitmap; 44 | bool fReplicated; 45 | BTextView *fText; 46 | }; 47 | 48 | #endif // OVERLAY_VIEW_H 49 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayWindow.cpp.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #include "OverlayView.h" 15 | #include "OverlayWindow.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #undef B_TRANSLATE_CONTEXT 23 | #define B_TRANSLATE_CONTEXT "Main window" 24 | 25 | 26 | OverlayWindow::OverlayWindow() 27 | : 28 | BWindow(BRect(50, 50, 500, 200), "OverlayImage", 29 | B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) 30 | { 31 | OverlayView *replView = new OverlayView(Bounds()); 32 | AddChild(replView); 33 | 34 | BView *bgView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); 35 | bgView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 36 | AddChild(bgView); 37 | } 38 | 39 | 40 | bool 41 | OverlayWindow::QuitRequested() 42 | { 43 | be_app->PostMessage(B_QUIT_REQUESTED); 44 | return true; 45 | } 46 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/.svn/text-base/OverlayWindow.h.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #ifndef OVERLAY_WINDOW_H 15 | #define OVERLAY_WINDOW_H 16 | 17 | #include 18 | #include 19 | 20 | 21 | class OverlayWindow : public BWindow { 22 | public: 23 | OverlayWindow(); 24 | virtual bool QuitRequested(); 25 | }; 26 | 27 | #endif // OVERLAY_WINDOW_H 28 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/Jamfile: -------------------------------------------------------------------------------- 1 | SubDir HAIKU_TOP src apps overlayimage ; 2 | 3 | Application OverlayImage : 4 | OverlayApp.cpp 5 | OverlayView.cpp 6 | OverlayWindow.cpp 7 | 8 | : be libtranslation.so $(TARGET_LIBSTDC++) $(HAIKU_LOCALE_LIBS) 9 | : OverlayImage.rdef 10 | ; 11 | 12 | DoCatalogs OverlayImage : 13 | x-vnd.Haiku-OverlayImage 14 | : 15 | OverlayWindow.cpp 16 | ; 17 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayApp.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #include "OverlayApp.h" 15 | #include "OverlayWindow.h" 16 | 17 | 18 | OverlayApp::OverlayApp() 19 | : BApplication("application/x-vnd.Haiku-OverlayImage") 20 | { 21 | OverlayWindow *theWindow = new OverlayWindow(); 22 | theWindow->Show(); 23 | } 24 | 25 | 26 | int 27 | main() 28 | { 29 | OverlayApp theApp; 30 | theApp.Run(); 31 | return (0); 32 | } 33 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayApp.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #ifndef OVERLAY_APP_H 15 | #define OVERLAY_APP_H 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | class OverlayApp : public BApplication { 23 | public: 24 | OverlayApp(); 25 | }; 26 | 27 | #endif // OVERLAY_APP_H 28 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayImage.rdef: -------------------------------------------------------------------------------- 1 | resource app_signature "application/x-vnd.Haiku-OverlayImage"; 2 | 3 | resource app_flags B_MULTIPLE_LAUNCH; 4 | 5 | resource app_version { 6 | major = 0, 7 | middle = 9, 8 | minor = 0, 9 | 10 | /* 0 = development 1 = alpha 2 = beta 11 | 3 = gamma 4 = golden master 5 = final */ 12 | variety = 5, 13 | 14 | internal = 0, 15 | 16 | short_info = "Replicantable Image Viewer", 17 | long_info = "View an image and put it as replicant e.g. on the Desktop" 18 | }; 19 | 20 | resource vector_icon { 21 | $"6E6369660502000603399E0F3D9C0ABF82B23B84A84B88504870C900F0D733BC" 22 | $"FFFEEAFFE0F154050105FF04019203FF00A7050606AE0B284033C3AE2A44BE00" 23 | $"C5EC4454543C4430C5A6BACF3E2E3C28020ABB1EBB84BB1EBB84BB1EBB842E3A" 24 | $"3038B784BE6B2C40B68DBF7130413A423243404044404242C222BEF54C3E4E40" 25 | $"C43EBEAA4E3CC3EFBE67C6B9BDE84A36C673BC10C0FDBB773A3ABF31BC71363C" 26 | $"323C343CB8EDBDDB020248404A404640484444444C440202C65EBE74C6D2BE67" 27 | $"C5EDBE81C653BF0DC5C5BEDAC6DEBF400A04304A30504250424A080A03010002" 28 | $"4014CABE1A903E2F65402966C834CE48FF1D0A01010012BC3AE4C02527402527" 29 | $"BC3AE443BD604C697101178400040A00010002BC3FE0C029F24029F2BC3FE043" 30 | $"99B24C6BC80A0403010203023F66E5B3B70FB829F03FF40743681746AB1E0A02" 31 | $"0104023CF34B3F5F71BFB7D13CAD2B4B19BAC8C4530A010104123CF34B3F5F71" 32 | $"BFB7D13CAD2B4B19BAC8C45301178200040A02010402BF34E93E641CBE641CBF" 33 | $"34E94CFF874AC2190A01010412BF34E93E641CBE641CBF34E94CFF874AC21901" 34 | $"17820004" 35 | }; 36 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayView.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #include "OverlayView.h" 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #undef B_TRANSLATE_CONTEXT 23 | #define B_TRANSLATE_CONTEXT "Main window" 24 | 25 | const float kDraggerSize = 7; 26 | 27 | 28 | OverlayView::OverlayView(BRect frame) 29 | : 30 | BView(frame, "OverlayImage", B_FOLLOW_NONE, B_WILL_DRAW) 31 | { 32 | fBitmap = NULL; 33 | fReplicated = false; 34 | 35 | frame.left = frame.right - kDraggerSize; 36 | frame.top = frame.bottom - kDraggerSize; 37 | BDragger *dragger = new BDragger(frame, this, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); 38 | AddChild(dragger); 39 | 40 | SetViewColor(B_TRANSPARENT_COLOR); 41 | 42 | fText = new BTextView(Bounds(), "bgView", Bounds(), B_FOLLOW_ALL, B_WILL_DRAW); 43 | fText->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 44 | AddChild(fText); 45 | BString text; 46 | text << B_TRANSLATE( 47 | "Enable \"Show replicants\" in Deskbar.\n" 48 | "Drag & drop an image.\n" 49 | "Drag the replicant to the Desktop."); 50 | fText->SetText(text); 51 | fText->SetAlignment(B_ALIGN_CENTER); 52 | fText->MakeSelectable(false); 53 | fText->MoveBy(0, (Bounds().bottom - fText->TextRect().bottom) / 2); 54 | } 55 | 56 | 57 | OverlayView::OverlayView(BMessage *archive) 58 | : 59 | BView(archive) 60 | { 61 | fReplicated = true; 62 | fBitmap = new BBitmap(archive); 63 | } 64 | 65 | 66 | OverlayView::~OverlayView() 67 | { 68 | delete fBitmap; 69 | } 70 | 71 | 72 | void 73 | OverlayView::Draw(BRect) 74 | { 75 | SetDrawingMode(B_OP_ALPHA); 76 | SetViewColor(B_TRANSPARENT_COLOR); 77 | 78 | if (fBitmap) 79 | DrawBitmap(fBitmap, B_ORIGIN); 80 | } 81 | 82 | 83 | void 84 | OverlayView::MessageReceived(BMessage *msg) 85 | { 86 | switch (msg->what) { 87 | case B_SIMPLE_DATA: 88 | { 89 | if (fReplicated) 90 | break; 91 | 92 | entry_ref ref; 93 | msg->FindRef("refs", &ref); 94 | BEntry entry(&ref); 95 | BPath path(&entry); 96 | 97 | delete fBitmap; 98 | fBitmap = BTranslationUtils::GetBitmap(path.Path()); 99 | 100 | if (fBitmap != NULL) { 101 | if (fText != NULL) { 102 | RemoveChild(fText); 103 | fText = NULL; 104 | } 105 | 106 | BRect rect = fBitmap->Bounds(); 107 | if (!fReplicated) { 108 | Window()->ResizeTo(rect.right, rect.bottom); 109 | Window()->Activate(true); 110 | } 111 | ResizeTo(rect.right, rect.bottom); 112 | Invalidate(); 113 | } 114 | break; 115 | } 116 | case B_ABOUT_REQUESTED: 117 | OverlayAboutRequested(); 118 | break; 119 | 120 | default: 121 | BView::MessageReceived(msg); 122 | break; 123 | } 124 | } 125 | 126 | 127 | BArchivable *OverlayView::Instantiate(BMessage *data) 128 | { 129 | return new OverlayView(data); 130 | } 131 | 132 | 133 | status_t 134 | OverlayView::Archive(BMessage *archive, bool deep) const 135 | { 136 | BView::Archive(archive, deep); 137 | 138 | archive->AddString("add_on", "application/x-vnd.Haiku-OverlayImage"); 139 | archive->AddString("class", "OverlayImage"); 140 | 141 | if (fBitmap) { 142 | fBitmap->Lock(); 143 | fBitmap->Archive(archive); 144 | fBitmap->Unlock(); 145 | } 146 | //archive->PrintToStream(); 147 | 148 | return B_OK; 149 | } 150 | 151 | 152 | void 153 | OverlayView::OverlayAboutRequested() 154 | { 155 | BAlert *alert = new BAlert("about", 156 | "OverlayImage\n" 157 | "Copyright 1999-2010\n\n\t" 158 | "originally by Seth Flaxman\n\t" 159 | "modified by Hartmuth Reh\n\t" 160 | "further modified by Humdinger\n", 161 | "OK"); 162 | 163 | BTextView *view = alert->TextView(); 164 | BFont font; 165 | view->SetStylable(true); 166 | view->GetFont(&font); 167 | font.SetSize(font.Size() + 7.0f); 168 | font.SetFace(B_BOLD_FACE); 169 | view->SetFontAndColor(0, 12, &font); 170 | 171 | alert->Go(); 172 | } 173 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayView.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #ifndef OVERLAY_VIEW_H 15 | #define OVERLAY_VIEW_H 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | class _EXPORT OverlayView; 30 | 31 | class OverlayView : public BView { 32 | public: 33 | OverlayView(BRect frame); 34 | OverlayView(BMessage *data); 35 | ~OverlayView(); 36 | virtual void Draw(BRect); 37 | virtual void MessageReceived(BMessage *msg); 38 | static BArchivable *Instantiate(BMessage *archive); 39 | virtual status_t Archive(BMessage *data, bool deep = true) const; 40 | void OverlayAboutRequested(); 41 | 42 | private: 43 | BBitmap *fBitmap; 44 | bool fReplicated; 45 | BTextView *fText; 46 | }; 47 | 48 | #endif // OVERLAY_VIEW_H 49 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayWindow.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #include "OverlayView.h" 15 | #include "OverlayWindow.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #undef B_TRANSLATE_CONTEXT 23 | #define B_TRANSLATE_CONTEXT "Main window" 24 | 25 | 26 | OverlayWindow::OverlayWindow() 27 | : 28 | BWindow(BRect(50, 50, 500, 200), "OverlayImage", 29 | B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) 30 | { 31 | OverlayView *replView = new OverlayView(Bounds()); 32 | AddChild(replView); 33 | 34 | BView *bgView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); 35 | bgView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 36 | AddChild(bgView); 37 | } 38 | 39 | 40 | bool 41 | OverlayWindow::QuitRequested() 42 | { 43 | be_app->PostMessage(B_QUIT_REQUESTED); 44 | return true; 45 | } 46 | -------------------------------------------------------------------------------- /volume2/Sources/overlayimage/OverlayWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1999-2010, Be Incorporated. All Rights Reserved. 3 | * This file may be used under the terms of the Be Sample Code License. 4 | * 5 | * OverlayImage is based on the code presented in this article: 6 | * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer 7 | * 8 | * Authors: 9 | * Seth Flexman 10 | * Hartmuth Reh 11 | * Humdinger 12 | */ 13 | 14 | #ifndef OVERLAY_WINDOW_H 15 | #define OVERLAY_WINDOW_H 16 | 17 | #include 18 | #include 19 | 20 | 21 | class OverlayWindow : public BWindow { 22 | public: 23 | OverlayWindow(); 24 | virtual bool QuitRequested(); 25 | }; 26 | 27 | #endif // OVERLAY_WINDOW_H 28 | -------------------------------------------------------------------------------- /volume2/Sources/printres.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | BString 6 | Int32Code2String(const int32 &code) 7 | { 8 | // Used to translate 32-bit integers into the 4-character constants 9 | // often used for formats and BMessage what fields. 10 | BString out("'"); 11 | out << (char)((code & 0xFF000000) >> 24) 12 | << (char)((code & 0x00FF0000) >> 16) 13 | << (char)((code & 0x0000FF00) >> 8) 14 | << (char)((code & 0x000000FF)) 15 | << "'"; 16 | return out; 17 | } 18 | 19 | 20 | void 21 | PrintResources(const char *path) 22 | { 23 | // This particular version of the BResources constructor is not found in 24 | // BeOS or Zeta, but it can easily be replaced by another version which takes 25 | // a BFile object instead. 26 | BResources res(path); 27 | if (res.InitCheck() != B_OK) 28 | return; 29 | 30 | // Reading resources from a file follows yet another usage pattern occasionally 31 | // found in the API: giving a function an index until the read function fails. 32 | // In this case, we create an index variable, attempt to read the resource at 33 | // that index, and if we succeed, do what we want with the information obtained, 34 | // increment the index, and repeat until the call fails. This usage pattern is 35 | // most commonly done with reading entry_refs from a BMessage. 36 | int32 resIndex = 0; 37 | type_code resType; 38 | int32 resID; 39 | const char *resName; 40 | size_t resSize; 41 | 42 | printf("Resources in file %s:\n", path); 43 | bool resourceFound = false; 44 | while (res.GetResourceInfo(resIndex, &resType, &resID, &resName, &resSize)) 45 | { 46 | resourceFound = true; 47 | BString line; 48 | line << "\t" << Int32Code2String(resType) << "\t" << resID; 49 | if (resName) 50 | line << "\t" << resName; 51 | 52 | line << "\t" << resSize << " bytes"; 53 | printf("%s\n", line.String()); 54 | resIndex++; 55 | } 56 | if (!resourceFound) 57 | printf("\tNone\n"); 58 | } 59 | 60 | 61 | int 62 | main(int argc, char **argv) 63 | { 64 | if (argc == 2) 65 | PrintResources(argv[1]); 66 | else 67 | printf("Usage: %s \n", argv[0]); 68 | 69 | return 0; 70 | } 71 | -------------------------------------------------------------------------------- /volume2/chapters/disclaimer.Md: -------------------------------------------------------------------------------- 1 | # Disclaimer {.unnumbered} 2 | 3 | **Original title: Programming with Haiku** 4 | 5 | *Copyright © 2010 by Jon Yoder* 6 | 7 | ### Notice of liability {.unnumbered} 8 | 9 | Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an "as is" basis. The author and Lulu.com shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. 10 | 11 | ### Trademarks {.unnumbered} 12 | 13 | Haiku and the Haiku logo are trademarks of Haiku, Inc. Be, BeOS, and the Be and BeOS logos are registered trademarks of Be Incorporated in the United States of America and other countries. All other products and company names mentioned in this book may be trademarks of their respective owners. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. 14 | 15 | ### License {.unnumbered} 16 | 17 | This work is licensed under the 18 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 19 | 20 | To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. 21 | 22 | ![](images/cc-by-nc-sa.png) 23 | 24 | -------------------------------------------------------------------------------- /volume2/images/ColorWellDemo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/ColorWellDemo1.png -------------------------------------------------------------------------------- /volume2/images/FileType.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/FileType.png -------------------------------------------------------------------------------- /volume2/images/FontDemo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/FontDemo1.png -------------------------------------------------------------------------------- /volume2/images/Icon-O-Matic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/Icon-O-Matic.png -------------------------------------------------------------------------------- /volume2/images/QuickRes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/QuickRes.png -------------------------------------------------------------------------------- /volume2/images/ResEdit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/ResEdit.png -------------------------------------------------------------------------------- /volume2/images/cc-by-nc-sa.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/cc-by-nc-sa.png -------------------------------------------------------------------------------- /volume2/images/cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theclue/programming-with-haiku/7117a657d8071ebfb98baf4d9431ec4c108379ae/volume2/images/cover.png -------------------------------------------------------------------------------- /volume2/metadata.yml: -------------------------------------------------------------------------------- 1 | --- 2 | title: Programming with Haiku 3 | subtitle: Advanced Topics 4 | author: Jon Yoder 5 | rights: Creative Commons Attribution 4.0 International 6 | language: en-US 7 | abstract: | 8 | This beginning programming guide takes the reader from know next to nothing 9 | about developing applications for the Haiku operating system to knowing the 10 | basics and having the skills to go beyond the fundamentals. It begins with 11 | a traditional "Hello, world! approach, moves through C programming, and 12 | expands into C++ and programming graphical applications for Haiku. 13 | Instead of attempting to be an exhaustive C/C++ programming book using Haiku, 14 | it focuses on application development using the C++ language. 15 | The Haiku operating system is a great platform for aspiring developers. 16 | Those who have struggled with learning application development under Linux, 17 | Microsoft Windows, or Macintosh will find writing programs under Haiku to be 18 | sensible and easy. The free Paladin integrated development environment for 19 | Haiku is used for examples in the book. 20 | pandoc-latex-environment: 21 | noteblock: [note] 22 | tipblock: [tip] 23 | warningblock: [warning] 24 | cautionblock: [caution] 25 | importantblock: [important] 26 | questionblock: [question] 27 | errorblock: [error] 28 | shellerrorblock: [shellerror] 29 | assignmentblock: [assignment] 30 | toughblock: [tough] 31 | bughuntblock: [bughunt] 32 | bugwarningblock: [bugwarning] 33 | ... 34 | -------------------------------------------------------------------------------- /volume2/rc help.txt: -------------------------------------------------------------------------------- 1 | 2 | Haiku Resource Compiler 1.1 3 | 4 | To compile an rdef script into a resource file: 5 | rc [options] [-o ] ... 6 | 7 | To convert a resource file back into an rdef script: 8 | rc [options] [-o ] -d ... 9 | 10 | Options: 11 | -d --decompile create an rdef script from a resource file 12 | --auto-names construct resource names from ID symbols 13 | -h --help show this message 14 | -I --include add to the list of include paths 15 | -m --merge do not erase existing contents of output file 16 | -o --output specify output file name, default is out.xxx 17 | -q --quiet do not display any error messages 18 | -V --version show software version and license 19 | -------------------------------------------------------------------------------- /volume2/xres help.txt: -------------------------------------------------------------------------------- 1 | Common usage: xres -o appname resfilename 2 | 3 | Usage: xres ( -h | --help ) 4 | xres -l ... 5 | xres ... 6 | 7 | The first form prints this help text and exits. 8 | 9 | The second form lists the resources of all given files. 10 | 11 | The third form manipulates the resources of one or more files according to 12 | the given commands. 13 | 14 | Valid commands are: 15 | 16 | - Add the resources read from file to the current 17 | output file. The file can either be a resource file or an 18 | executable file. 19 | -a :[:] ( | -s ) 20 | - Add a resource to the current output file. The added resource is 21 | of type and has the ID . If given the resource will 22 | have name , otherwise it won't have a name. The resource 23 | data will either be the string provided on the command 24 | line or the data read from file (the whole contents). 25 | -d [:] 26 | - Excludes resources with type and, if given, ID from 27 | being written to the output file. This applies to all resources 28 | read from input files or directly specified via command "-a" 29 | following this command until the next "-d" command. 30 | -o 31 | - Changes the output file to . All resources specified 32 | by subsequent or "-a" commands will be written 33 | to this file until the next output file is specified via the 34 | "-o" command. Resources specified later overwrite earlier ones 35 | with the same type and ID. If doesn't exist yet, 36 | a resource file with the name will be created. If it exists and 37 | is an executable file, the resources will be added to it (if the 38 | file already has resources, they will be removed before). If it 39 | is a resource file or a file of unknown type, it will be 40 | overwritten with a resource file containing the specified 41 | resources. The initial output file is "xres.output.rsrc". 42 | Note that an output file will only be created or modified, if at 43 | least one or "-a" command is given for it. 44 | -x [:] 45 | - Only resources with type and, if given, ID will be 46 | written to the output file. This applies to all resources 47 | read from input files or directly specified via command "-a" 48 | following this command until the next "-x" command. 49 | -- - All following arguments, even if starting with a "-" character, 50 | are treated as input file names. 51 | 52 | Parameters: 53 | - A type constant consisting of exactly four characters. 54 | - A positive or negative integer. 55 | --------------------------------------------------------------------------------