| 1 |
// -*- C++ -*- |
| 2 |
// $Id: LabelManagerDriver.h 16081 2011-09-16 07:55:54Z aleksandr $ |
| 3 |
|
| 4 |
// DYMO LabelWriter Drivers |
| 5 |
// Copyright (C) 2008 Sanford L.P. |
| 6 |
|
| 7 |
// This program is free software; you can redistribute it and/or |
| 8 |
// modify it under the terms of the GNU General Public License |
| 9 |
// as published by the Free Software Foundation; either version 2 |
| 10 |
// of the License, or (at your option) any later version. |
| 11 |
|
| 12 |
// This program is distributed in the hope that it will be useful, |
| 13 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
// GNU General Public License for more details. |
| 16 |
|
| 17 |
// You should have received a copy of the GNU General Public License |
| 18 |
// along with this program; if not, write to the Free Software |
| 19 |
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 20 |
|
| 21 |
#ifndef ha9145701_1d7d_46f6_a726_773510223757 |
| 22 |
#define ha9145701_1d7d_46f6_a726_773510223757 |
| 23 |
|
| 24 |
#include "PrinterDriver.h" |
| 25 |
#include <string> |
| 26 |
|
| 27 |
|
| 28 |
namespace DymoPrinterDriver |
| 29 |
{ |
| 30 |
|
| 31 |
|
| 32 |
/** |
| 33 |
Driver for the printers supported LabelWriter command set |
| 34 |
*/ |
| 35 |
class CLabelManagerDriver: public IPrinterDriver |
| 36 |
{ |
| 37 |
public: |
| 38 |
typedef enum |
| 39 |
{ |
| 40 |
tw6mm = 0, |
| 41 |
tw9mm, |
| 42 |
tw12mm, |
| 43 |
tw19mm, |
| 44 |
tw24mm, |
| 45 |
tw32mm |
| 46 |
} tape_width_t; |
| 47 |
|
| 48 |
typedef enum |
| 49 |
{ |
| 50 |
coCut = 0, |
| 51 |
coChainMarks |
| 52 |
} cut_t; |
| 53 |
|
| 54 |
typedef enum |
| 55 |
{ |
| 56 |
alCenter = 0, |
| 57 |
alLeft, |
| 58 |
alRight |
| 59 |
} alignment_t; |
| 60 |
|
| 61 |
typedef enum |
| 62 |
{ |
| 63 |
tcBlackOnWhite = 0, |
| 64 |
tcBlackOnBlue, |
| 65 |
tcBlackOnRed, |
| 66 |
tcBlackOnSilver, |
| 67 |
tcBlackOnYellow, |
| 68 |
tcBlackOnGold, |
| 69 |
tcBlackOnGreen, |
| 70 |
tcBlackOnFluorescentGreen, |
| 71 |
tcBlackOnFluorescentRed, |
| 72 |
tcWhiteOnClear, |
| 73 |
tcWhiteOnBlack, |
| 74 |
tcBlueOnWhite, |
| 75 |
tcRedOnWhite |
| 76 |
} tape_color_t; |
| 77 |
|
| 78 |
CLabelManagerDriver(IPrintEnvironment& Environment); |
| 79 |
virtual ~CLabelManagerDriver(); |
| 80 |
|
| 81 |
virtual void StartDoc(); |
| 82 |
virtual void EndDoc(); |
| 83 |
|
| 84 |
virtual void StartPage(); |
| 85 |
virtual void EndPage(); |
| 86 |
|
| 87 |
virtual void ProcessRasterLine(const buffer_t& LineBuffer); |
| 88 |
|
| 89 |
void SetDeviceName(const std::string& DeviceName); |
| 90 |
void SetSupportAutoCut(bool Value); |
| 91 |
void SetTSDevice(bool Value); |
| 92 |
void SetCutOptions(cut_t Value); |
| 93 |
void SetAlignment(alignment_t Value); |
| 94 |
void SetContinuousPaper(bool Value); |
| 95 |
void SetPrintChainMarksAtDocEnd(bool Value); |
| 96 |
void SetAutoPaper(bool Value); |
| 97 |
void SetTapeAlignmentOffset(int Value); |
| 98 |
void SetTapeColor(tape_color_t Value); |
| 99 |
|
| 100 |
void SetMaxPrintableWidth(size_t Value); |
| 101 |
void SetNormalLeader(size_t Value); |
| 102 |
void SetMinLeader(size_t Value); |
| 103 |
void SetAlignedLeader(size_t Value); |
| 104 |
void SetMinPageLines(size_t Value); |
| 105 |
|
| 106 |
const std::string& GetDeviceName(); |
| 107 |
bool IsSupportAutoCut(); |
| 108 |
bool IsTSDevice(); |
| 109 |
cut_t GetCutOptions(); |
| 110 |
alignment_t GetAlignment(); |
| 111 |
bool IsContinuousPaper(); |
| 112 |
bool IsPrintChainMarksAtDocEnd(); |
| 113 |
bool IsAutoPaper(); |
| 114 |
tape_color_t GetTapeColor(); |
| 115 |
int GetTapeAlignmentOffset(); |
| 116 |
size_t GetMaxPrintableWidth(); |
| 117 |
size_t GetNormalLeader(); |
| 118 |
size_t GetMinLeader(); |
| 119 |
size_t GetAlignedLeader(); |
| 120 |
size_t GetMinPageLines(); |
| 121 |
|
| 122 |
static buffer_t GetRequestStatusCommand(); |
| 123 |
|
| 124 |
protected: |
| 125 |
// helper function to send printer commands |
| 126 |
void SendCommand(const byte* Buf, size_t BufSize); |
| 127 |
void SendCommand(const buffer_t& Buf); |
| 128 |
void SendCommandTS(const buffer_t& Buf); |
| 129 |
void FlushCommandTS(); |
| 130 |
void EndCommandTS(); |
| 131 |
void SendDotTab(size_t Value); |
| 132 |
void SendCut(); |
| 133 |
void SendChainMark(); |
| 134 |
void SendBytesPerLine(size_t Value); |
| 135 |
void SendSkipLines(size_t Value); |
| 136 |
void SendTapeColor(tape_color_t Value); |
| 137 |
|
| 138 |
void GetBlanks(const buffer_t& Buf, size_t& LeaderBlanks, size_t& TrailerBlanks); |
| 139 |
|
| 140 |
size_t GetMaxBytesPerLine(); |
| 141 |
private: |
| 142 |
IPrintEnvironment& Environment_; |
| 143 |
|
| 144 |
// job params |
| 145 |
cut_t CutOptions_; |
| 146 |
alignment_t Alignment_; |
| 147 |
bool ContinuousPaper_; |
| 148 |
bool PrintChainMarksAtDocEnd_; |
| 149 |
bool AutoPaper_; // don't send last empty lines |
| 150 |
int TapeAlignmentOffset_; // offset to justify output for the current label type . it is different for different tape sizes and models |
| 151 |
tape_color_t TapeColor_; |
| 152 |
|
| 153 |
// device params |
| 154 |
std::string DeviceName_; |
| 155 |
bool SupportAutoCut_; |
| 156 |
bool TSDevice_; |
| 157 |
size_t MaxPrintableWidth_; // in dots |
| 158 |
size_t NormalLeader_; |
| 159 |
size_t MinLeader_; |
| 160 |
size_t AlignedLeader_; |
| 161 |
size_t MinPageLines_; |
| 162 |
|
| 163 |
// job internal variables |
| 164 |
size_t LastDotTab_; |
| 165 |
size_t LastBytesPerLine_; |
| 166 |
size_t EmptyLinesCount_; |
| 167 |
size_t PageNo_; |
| 168 |
size_t PageLineCount_; |
| 169 |
|
| 170 |
std::vector<buffer_t> RasterLines_; |
| 171 |
buffer_t ShiftedRasterLine_; |
| 172 |
|
| 173 |
buffer_t TSBuffer_; |
| 174 |
|
| 175 |
FILE* HLockFile_; |
| 176 |
void ProcessRasterLineInternal(const buffer_t& LineBuffer); |
| 177 |
void SendCachedRasterLines(); |
| 178 |
void ShiftData(const buffer_t& Buf, buffer_t& ShiftedBuf, int ShiftValue); |
| 179 |
void ShiftDataLeft(const buffer_t& Buf, buffer_t& ShiftedBuf, size_t ShiftValue); |
| 180 |
void ShiftDataRight(const buffer_t& Buf, buffer_t& ShiftedBuf, size_t ShiftValue); |
| 181 |
int GetShiftValue(size_t RasterLineSize); |
| 182 |
}; |
| 183 |
|
| 184 |
|
| 185 |
}; //namespace |
| 186 |
|
| 187 |
#endif |
| 188 |
|
| 189 |
/* |
| 190 |
* End of "$Id: LabelManagerDriver.h 16081 2011-09-16 07:55:54Z aleksandr $". |
| 191 |
*/ |