diff -Naur ebi-1.2.4/ebi/src/ebi.d ebi-1.2.4c/ebi/src/ebi.d --- ebi-1.2.4/ebi/src/ebi.d 2002-05-24 23:28:23.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi.d 2006-09-01 16:58:40.000000000 +0900 @@ -192,6 +192,8 @@ MC_STR "著作権情報" MC_LINE MC_STRKEY1 "T" "書籍一覧" + MC_LINE + MC_STRKEY1 "C" "コピー" 0 -------------------- .mn_page: MC_STR "ページ操作" @@ -217,6 +219,8 @@ 0x203 5 0 -- 著作権情報 --204 0 -- ------------ 0x205 6 0 -- 書籍一覧 + --206 0 -- ------------ + 0x207 9 0 -- コピー -- ページ操作 0x301 7 0 -- 前の履歴へ 0x302 8 0 -- 次の履歴へ diff -Naur ebi-1.2.4/ebi/src/ebi.h ebi-1.2.4c/ebi/src/ebi.h --- ebi-1.2.4/ebi/src/ebi.h 2001-09-13 23:11:14.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi.h 2006-09-01 16:58:51.000000000 +0900 @@ -22,6 +22,8 @@ #include "ebi_book.h" #include "ebi_pageset.h" +#include "tray.h" + __EBI_BEGIN_NAMESPACE extern Fusen g_fusen; @@ -29,6 +31,7 @@ extern Menu g_menu; extern Book g_book; extern PageSet g_pageSet; +extern Tray g_tray; class Reference; diff -Naur ebi-1.2.4/ebi/src/ebi_bitmap.cc ebi-1.2.4c/ebi/src/ebi_bitmap.cc --- ebi-1.2.4/ebi/src/ebi_bitmap.cc 2001-10-10 00:13:02.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_bitmap.cc 2006-09-01 19:31:23.000000000 +0900 @@ -14,6 +14,7 @@ #include "ebi_bitmap.h" #include "ebi_error.h" +#include "ebi.h" __EBI_BEGIN_NAMESPACE @@ -123,6 +124,12 @@ } } +void Bitmap::addTray() +{ + g_tray.addBMP(&m_cspec, &m_bmp); +} + + static ERR readJpegBinary (UB* bytes, UW reqSize, VOID* source) { BinaryInfo* binary = (BinaryInfo*) source; diff -Naur ebi-1.2.4/ebi/src/ebi_bitmap.h ebi-1.2.4c/ebi/src/ebi_bitmap.h --- ebi-1.2.4/ebi/src/ebi_bitmap.h 2001-10-08 00:47:56.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_bitmap.h 2006-09-01 19:46:39.000000000 +0900 @@ -31,7 +31,9 @@ bool convertJpeg (const char* bytes, int length); bool convertBitmap (const char* bytes, int length); void draw (GID gid, W x, W y); - + void addTray(); + const RECT* getBounds() const { return &m_bmp.bounds; } + private: BMP m_bmp; CSPEC m_cspec; diff -Naur ebi-1.2.4/ebi/src/ebi_bitmapfont.cc ebi-1.2.4c/ebi/src/ebi_bitmapfont.cc --- ebi-1.2.4/ebi/src/ebi_bitmapfont.cc 2001-10-06 16:41:27.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_bitmapfont.cc 2006-09-01 20:58:08.000000000 +0900 @@ -14,6 +14,7 @@ #include "ebi_bitmapfont.h" #include "ebi_error.h" +#include "ebi.h" __EBI_BEGIN_NAMESPACE @@ -71,4 +72,13 @@ } } +void BitmapFont::addTray() +{ + COLOR color[2] = { 0x10ffffff, 0x10000000 }; + CSPEC cspec = { 0x09, { 2 }, color }; + g_tray.addGraph(&m_bmp.bounds); + g_tray.addBMP(&cspec, &m_bmp); + g_tray.addGraphEnd(); +} + __EBI_END_NAMESPACE diff -Naur ebi-1.2.4/ebi/src/ebi_bitmapfont.h ebi-1.2.4c/ebi/src/ebi_bitmapfont.h --- ebi-1.2.4/ebi/src/ebi_bitmapfont.h 2001-10-06 16:41:31.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_bitmapfont.h 2006-09-01 19:31:24.000000000 +0900 @@ -26,7 +26,7 @@ virtual ~BitmapFont (); void draw (GID gid, RECT * rect, COLOR fgColor, COLOR bgColor); - + virtual void addTray(); private: BMP m_bmp; }; diff -Naur ebi-1.2.4/ebi/src/ebi_char.cc ebi-1.2.4c/ebi/src/ebi_char.cc --- ebi-1.2.4/ebi/src/ebi_char.cc 2001-10-08 01:09:25.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_char.cc 2006-09-01 17:04:16.000000000 +0900 @@ -14,6 +14,7 @@ #include "ebi_char.h" #include "ebi_device.h" +#include "ebi.h" __EBI_BEGIN_NAMESPACE @@ -70,6 +71,17 @@ device->drawChar (m_code); } +void Char::addTray() +{ + if (m_fontType==FONT_HALF) { + g_tray.addRatio(1, 2); + } else { + g_tray.addRatio(1, 1); + } + g_tray.add(0, &m_code, sizeof(TC)); +} + + bool Char::isHit (const PNT& pnt) const { if ((pnt.x >= m_pnt.x && pnt.x < m_pnt.x + m_width) && pnt.y == m_pnt.y) @@ -84,4 +96,5 @@ *str += m_code; } + __EBI_END_NAMESPACE diff -Naur ebi-1.2.4/ebi/src/ebi_char.h ebi-1.2.4c/ebi/src/ebi_char.h --- ebi-1.2.4/ebi/src/ebi_char.h 2001-10-08 01:09:24.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_char.h 2006-08-31 21:05:40.000000000 +0900 @@ -33,6 +33,7 @@ virtual void draw (Device* device, W low, W high); virtual bool isHit (const PNT& pnt) const; virtual void getString (String* str) const; + virtual void addTray(); private: TC m_code; diff -Naur ebi-1.2.4/ebi/src/ebi_container.cc ebi-1.2.4c/ebi/src/ebi_container.cc --- ebi-1.2.4/ebi/src/ebi_container.cc 2001-10-08 01:09:25.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_container.cc 2006-09-01 17:02:39.000000000 +0900 @@ -68,6 +68,14 @@ } } +void Container::addTray() +{ + for (Elements::iterator ei = m_elements.begin (); ei != m_elements.end (); ++ei) + { + (*ei)->addTray(); + } +} + bool Container::isHit (const PNT& pnt) const { for (Elements::const_iterator ei = m_elements.begin (); ei != m_elements.end (); ++ei) diff -Naur ebi-1.2.4/ebi/src/ebi_container.h ebi-1.2.4c/ebi/src/ebi_container.h --- ebi-1.2.4/ebi/src/ebi_container.h 2001-10-08 01:09:24.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_container.h 2006-09-01 16:58:50.000000000 +0900 @@ -36,6 +36,7 @@ void clear (); void addElement (Element * element); + void addTray(); protected: Elements m_elements; diff -Naur ebi-1.2.4/ebi/src/ebi_element.h ebi-1.2.4c/ebi/src/ebi_element.h --- ebi-1.2.4/ebi/src/ebi_element.h 2001-10-08 01:09:23.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_element.h 2006-08-31 19:05:33.000000000 +0900 @@ -36,6 +36,7 @@ virtual const Reference* getReference (const PNT& pnt) const; virtual bool isHit (const PNT& pnt) const = 0; virtual void getString (String* str) const = 0; + virtual void addTray() = 0; }; typedef std::list Elements; diff -Naur ebi-1.2.4/ebi/src/ebi_gaiji.cc ebi-1.2.4c/ebi/src/ebi_gaiji.cc --- ebi-1.2.4/ebi/src/ebi_gaiji.cc 2001-10-08 01:09:24.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_gaiji.cc 2006-09-01 19:31:24.000000000 +0900 @@ -20,6 +20,7 @@ #include "ebi_device.h" #include "ebi_fontset.h" #include "ebi_error.h" +#include "ebi.h" __EBI_BEGIN_NAMESPACE @@ -84,6 +85,14 @@ device->drawBitmapFont (bitmapFont, size); } +void Gaiji::addTray() +{ + Fontset* fontset = m_subbook->getBook ()->getFontset (); + BitmapFont *bitmapFont = fontset->getBitmapFont (m_subbook->getSubbook (), m_code, m_fontType); + bitmapFont->addTray(); +} + + bool Gaiji::isHit (const PNT& pnt) const { if ((pnt.x >= m_pnt.x && pnt.x < m_pnt.x + m_width) && pnt.y == m_pnt.y) diff -Naur ebi-1.2.4/ebi/src/ebi_gaiji.h ebi-1.2.4c/ebi/src/ebi_gaiji.h --- ebi-1.2.4/ebi/src/ebi_gaiji.h 2001-10-08 01:09:23.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_gaiji.h 2006-09-01 16:58:48.000000000 +0900 @@ -35,6 +35,7 @@ virtual void draw (Device* device, W low, W high); virtual bool isHit (const PNT& pnt) const; virtual void getString (String* str) const; + virtual void addTray(); protected: Subbook* m_subbook; diff -Naur ebi-1.2.4/ebi/src/ebi_imagepage.cc ebi-1.2.4c/ebi/src/ebi_imagepage.cc --- ebi-1.2.4/ebi/src/ebi_imagepage.cc 2001-10-09 00:13:27.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_imagepage.cc 2006-09-01 19:47:47.000000000 +0900 @@ -15,6 +15,7 @@ #include "ebi_imagepage.h" #include "ebi_error.h" #include "ebi_device.h" +#include "ebi.h" __EBI_BEGIN_NAMESPACE @@ -100,6 +101,16 @@ m_bitmap.draw (gid, x, y); } +void ImagePage::addTray() +{ + g_tray.clear(); + g_tray.addGraph(m_bitmap.getBounds()); + m_bitmap.addTray(); + g_tray.addGraphEnd(); + g_tray.doCopy(TR_FIG); +} + + W ImagePage::updateLayout () { if (m_device == NULL) diff -Naur ebi-1.2.4/ebi/src/ebi_imagepage.h ebi-1.2.4c/ebi/src/ebi_imagepage.h --- ebi-1.2.4/ebi/src/ebi_imagepage.h 2001-10-09 00:13:45.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_imagepage.h 2006-09-01 16:58:42.000000000 +0900 @@ -34,7 +34,8 @@ virtual const Reference* getReference (const PNT& pnt) const; bool addBinary (const char* binary, int length); bool convertBinary (ImageLink::ImageType type); - + virtual void addTray(); + private: char* m_binary; int m_length; diff -Naur ebi-1.2.4/ebi/src/ebi_main.cc ebi-1.2.4c/ebi/src/ebi_main.cc --- ebi-1.2.4/ebi/src/ebi_main.cc 2001-10-10 11:57:15.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_main.cc 2006-09-01 16:58:50.000000000 +0900 @@ -41,6 +41,7 @@ Menu g_menu; Book g_book; PageSet g_pageSet; +Tray g_tray; static W s_targetvid = -1; diff -Naur ebi-1.2.4/ebi/src/ebi_menu.cc ebi-1.2.4c/ebi/src/ebi_menu.cc --- ebi-1.2.4/ebi/src/ebi_menu.cc 2002-05-24 23:29:00.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_menu.cc 2006-09-01 16:58:39.000000000 +0900 @@ -171,6 +171,13 @@ return 0; } +W Menu::onCopy (W para) +{ + Page* p = g_pageSet.getCurrPage(); + if (p) p->addTray(); + return 0; +} + #if 0 W Menu::onForwardPage (W para) { @@ -239,6 +246,7 @@ s_funcs[MENU_FORWARDPAGE] = (FUNCP) onForwardPage; s_funcs[MENU_BACKWARDPAGE] = (FUNCP) onBackwardPage; #endif + s_funcs[MENU_COPY] = (FUNCP) onCopy; ERR err = openmenu (MN_MAIN); if (err < E_OK) diff -Naur ebi-1.2.4/ebi/src/ebi_menu.h ebi-1.2.4c/ebi/src/ebi_menu.h --- ebi-1.2.4/ebi/src/ebi_menu.h 2002-05-24 23:29:05.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_menu.h 2006-09-01 16:58:39.000000000 +0900 @@ -47,6 +47,7 @@ MENU_FORWARDPAGE, MENU_BACKWARDPAGE, #endif + MENU_COPY, MAX_MENU, }; @@ -68,6 +69,7 @@ static W onForwardPage (W para); static W onBackwardPage (W para); #endif + static W onCopy (W para); }; __EBI_END_NAMESPACE diff -Naur ebi-1.2.4/ebi/src/ebi_page.h ebi-1.2.4c/ebi/src/ebi_page.h --- ebi-1.2.4/ebi/src/ebi_page.h 2001-10-08 18:23:09.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_page.h 2006-09-01 16:58:42.000000000 +0900 @@ -36,7 +36,7 @@ virtual void draw (W low, W high) = 0; virtual W updateLayout () = 0; virtual const Reference* getReference (const PNT& pnt) const = 0; - + virtual void addTray() = 0; protected: Subbook* m_subbook; EB_Position m_pos; diff -Naur ebi-1.2.4/ebi/src/ebi_textpage.cc ebi-1.2.4c/ebi/src/ebi_textpage.cc --- ebi-1.2.4/ebi/src/ebi_textpage.cc 2001-10-08 18:23:09.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_textpage.cc 2006-09-01 19:47:37.000000000 +0900 @@ -14,6 +14,7 @@ #include "ebi_textpage.h" #include "ebi_device.h" +#include "ebi.h" __EBI_BEGIN_NAMESPACE @@ -71,6 +72,23 @@ } } +void TextPage::addTray() +{ + g_tray.clear(); + g_tray.addText(); + for (Lines::iterator li = m_lines.begin (); li != m_lines.end (); ++li) + { + TC c; + + (*li)->addTray(); + c = 0x0a; + g_tray.add(0, &c, sizeof(TC)); + } + g_tray.addTextEnd(); + g_tray.doCopy(TR_TEXT); +} + + const Reference* TextPage::getReference (const PNT& pnt) const { for (Lines::const_iterator li = m_lines.begin (); li != m_lines.end (); ++li) diff -Naur ebi-1.2.4/ebi/src/ebi_textpage.h ebi-1.2.4c/ebi/src/ebi_textpage.h --- ebi-1.2.4/ebi/src/ebi_textpage.h 2001-10-08 18:23:09.000000000 +0900 +++ ebi-1.2.4c/ebi/src/ebi_textpage.h 2006-09-01 16:58:40.000000000 +0900 @@ -34,7 +34,8 @@ virtual const Reference* getReference (const PNT& pnt) const; void addLine (Line * line); void deleteLine (Line * line); - + virtual void addTray(); + private: Lines m_lines; bool m_bNoFold; diff -Naur ebi-1.2.4/ebi/src/tray.h ebi-1.2.4c/ebi/src/tray.h --- ebi-1.2.4/ebi/src/tray.h 1970-01-01 09:00:00.000000000 +0900 +++ ebi-1.2.4c/ebi/src/tray.h 2006-09-01 20:55:10.000000000 +0900 @@ -0,0 +1,219 @@ +#ifndef _TRAY_H +#define _TRAY_H + +#include + +class Tray { + public: + int m_nBuffSize; + int m_nBuffPos; + UB* m_pBuff; + UH m_uhCurWidthRatio; + UH m_uhCurHeightRatio; + + Tray() { + m_nBuffSize = 0; + m_nBuffPos = 0; + m_pBuff = NULL; + m_uhCurWidthRatio = 0; + m_uhCurHeightRatio = 0; + } + + ~Tray() { + if (m_pBuff) { + delete m_pBuff; + m_pBuff = NULL; + } + m_nBuffSize = 0; + m_nBuffPos = 0; + } + + void clear() { + if (m_pBuff) { + delete m_pBuff; + m_pBuff = NULL; + } + m_nBuffSize = 0; + m_nBuffPos = 0; + } + + void add(UB segid, VP p, int len) { + int off; + + off = 1 + 1 + 2; + if (len > 65534) { + off = 1 + 1 + 1 + 1 + 4; + } + while (m_nBuffPos + off + len > m_nBuffSize) { + UB* new_buf; + + new_buf = new UB[m_nBuffSize + 512]; + if (m_pBuff) { + memcpy(new_buf, m_pBuff, m_nBuffPos); + delete m_pBuff; + m_pBuff = NULL; + } + m_pBuff = new_buf; + m_nBuffSize += 512; + } + + if (segid!=0) { + if (len > 65534) { + m_pBuff[m_nBuffPos++] = segid; + m_pBuff[m_nBuffPos++] = 0xff; + m_pBuff[m_nBuffPos++] = 0xff; + m_pBuff[m_nBuffPos++] = 0xff; + m_pBuff[m_nBuffPos++] = (UB)(((UW)len) & 0xff); + m_pBuff[m_nBuffPos++] = (UB)(((UW)len & 0x0000ff00) >> 8); + m_pBuff[m_nBuffPos++] = (UB)(((UW)len & 0x00ff0000) >> 16); + m_pBuff[m_nBuffPos++] = (UB)(((UW)len & 0xff000000) >> 24); + } else { + m_pBuff[m_nBuffPos++] = segid; + m_pBuff[m_nBuffPos++] = 0xff; + m_pBuff[m_nBuffPos++] = (UB)(((UW)len) & 0xff); + m_pBuff[m_nBuffPos++] = (UB)(((UW)len) >> 8); + } + } + memcpy(&m_pBuff[m_nBuffPos], p, len); + m_nBuffPos += len; + } + + + + void addText(RECT* r = NULL) { + TEXTSEG tad_t; + + memset(&tad_t, 0, sizeof(tad_t)); + if (r!=NULL) { + tad_t.view = *r; + tad_t.draw = *r; + } + tad_t.lang = 0x0021; // 日本語 + tad_t.bgpat = 0; // 透明パターン + add(TS_TEXT, &tad_t, sizeof(tad_t)); + } + + void addTextEnd() { + add(TS_TEXTEND, NULL, 0); + } + + // 幅の分子、分母、高さの分子、分母の順 + void addRatio(int w_n = 1, int w_d = 1, int h_n = 1, int h_d = 1) { + TT_RATIO tad_fratio; + UH hr, wr; + wr = ((UH)w_n << 8) | (UH)w_d; + hr = ((UH)h_n << 8) | (UH)h_d; + if (wr!=m_uhCurWidthRatio || hr!=m_uhCurHeightRatio) { + // 変化が無い場合はTADに付け加えない + memset(&tad_fratio, 0, sizeof(tad_fratio)); + tad_fratio.subid = TT_RATIO_SID; // 文字拡大 / 縮小指定付箋 + tad_fratio.h_ratio = hr; + tad_fratio.w_ratio = wr; + add(TS_TFONT, &tad_fratio, sizeof(tad_fratio)); + m_uhCurWidthRatio = wr; + m_uhCurHeightRatio = hr; + } + } + + void addChar(TC ch) { + add(0, &ch, sizeof(TC)); + } + + void addBMP(CSPEC* cspec, BMP* bmp) { + IMAGESEG* iseg; + UB* iseg_ub; + int sz; + int off_plane; + int off_color; + int plane_sz; + int i; + int colors; + + colors = 0; + plane_sz = bmp->rowbytes * (bmp->bounds.c.bottom - bmp->bounds.c.top); + if (plane_sz < 0) plane_sz *= -1; + sz = sizeof(IMAGESEG) + sizeof(UW) * (bmp->planes - 1); + off_plane = sz; + sz += plane_sz * bmp->planes; + off_color = sz; + if (cspec->attr & 0x08) { + colors = 1; + for(i=0; i<(int)(bmp->planes * (bmp->pixbits & 0xff)); i++) { + colors *= 2; + } + sz += sizeof(COLOR) * colors; + } + + iseg_ub = new UB[sz]; + iseg = (IMAGESEG*)iseg_ub; + memset(iseg, 0, sz); + iseg->view = bmp->bounds; + iseg->draw = bmp->bounds; + iseg->slope = 0; + iseg->color = cspec->attr & 0x0f; + iseg->cinfo[0] = cspec->info[0]; + iseg->cinfo[1] = cspec->info[1]; + iseg->cinfo[2] = cspec->info[2]; + iseg->cinfo[3] = cspec->info[3]; + if (cspec->attr & 0x08) { + // index color + iseg->cinfo[0] = colors * sizeof(COLOR); + iseg->cinfo[2] = (UH) (off_color >> 16); + iseg->cinfo[3] = (UH) (off_color & 0xffff); + for(i=0; iinfo[0]; i++) { + ((COLOR*)&iseg_ub[off_color])[i] = cspec->colmap[i]; + } + } + iseg->planes = bmp->planes; + iseg->pixbits = bmp->pixbits; + iseg->bounds = bmp->bounds; + iseg->rowbytes = bmp->rowbytes; + for(i=0; i<(int)bmp->planes; i++) { + iseg->base_off[i] = off_plane + plane_sz * i; + memcpy(&iseg_ub[iseg->base_off[i]], bmp->baseaddr[i], plane_sz); + } + add(TS_IMAGE, iseg_ub, sz); + delete iseg_ub; + } + + void addGraph(const RECT* r = NULL) { + FIGSEG tad_f; + + memset(&tad_f, 0, sizeof(tad_f)); + if (r!=NULL) { + tad_f.view = *r; + tad_f.draw = *r; + } + tad_f.h_unit = -120; // 試しに普通のデータをダンプしてみたらこうなっていた + tad_f.v_unit = -120; + tad_f.ratio = 1; + add(TS_FIG, &tad_f, sizeof(tad_f)); + } + + void addGraphEnd() { + add(TS_FIGEND, NULL, 0); + } + + void doCopy(int id = TR_TEXT) { + TRAYREC tr; + W err; + + tr.id = id; + tr.len = m_nBuffPos; + tr.dt = (B*)m_pBuff; + err = tpsh_dat(&tr, 1, NULL); + if (err < 0) { + switch(err) { + case EX_ADR: printf("EX_ADR\n"); break; + case EX_NOSPC: printf("EX_NOSPC\n"); break; + case EX_PAR: printf("EX_PAR\n"); break; + case EX_TRAY: printf("EX_TRAY\n"); break; + default: + printf("unknown\n"); break; + } + } + } + +}; + +#endif