/* * PicWidget.h * * Created on: Jul 2, 2013 * Author: yiyu * QQ:1036184468 * Descriptoin: */ #ifndef PICWIDGET_H_ #define PICWIDGET_H_ #include #include #include #include #include #include #include #include #include #include //#include #include "SysPara.h" #include "ParaSettingUI.h" #define MAX_PIC_WIDGET_HEIGHT 60 #define MAX_PIC_WIDGET_WIDTH 600*8 #define MAX_WIDTH MAX_PIC_WIDGET_WIDTH-100 #define MAX_HEIGHT MAX_PIC_WIDGET_HEIGHT #define MAXLINE 40 #define FVAR (1<<5) #define FCOL0 (1<<6) #define FLINE0 (1<<7) #define CFONT 0 #define CLINESPACE 1 #define CFONTGAP 2 #define CBOLD 3 #define CHEIGHT 4 #define VTYPE 1 #define VDIGIT 2 #define VWIDTH 3 #define VTYPE0 4 #define VTYPE1 5 //#define C 5 #define BIN0808 100 #define BIN0809 1000 #define BIN0810 2000 #define BIN0812 3000 #define BIN0816 5000 #define BIN1616 7000 #define BIN2424 11000 //#define BIN1224 15000 #define BIN0805 20000 //是否需要匹配字体能操作 //#define FONTMATCH typedef enum{ ST05=0, ST07=1, ST09=2, ST12=3, ST16=4, HT16=5, ST24=6, HT24=7, ST32=8 }PFONTNAME; typedef struct { bool DrawEn;// 绘图 bool DrawGridEn; // 网格 checkBoxDrawGridEn int Width;// 字串长度 unsigned char CharHeight; //字符高度 unsigned char CharWidth; //字符宽度 unsigned char FontGap; // 字符间隔 PFONTNAME Font;// 字体 bool CharCurrent; //光标类型,字符还是像素 bool CurrentEn; unsigned char LineSpace; unsigned char Bold; // 字体加粗 unsigned char LineHeight; bool insertMode; bool checkBoxControlChar;//控制符显示 } t_charPara; typedef struct{ int width; int height; bool enable; } t_draw; typedef struct{ int Len; int yPos; int xPos; int minFont; int maxFont; int minLineHeight; int maxLineHeight; }t_line; class PicWidget:public QWidget{ Q_OBJECT public: explicit PicWidget(QWidget *parent = 0); ~PicWidget(); void resizeWidget(int w,int h); void initWidget(int w,int h); void loadImage(QString filename,bool forceSize = true); void insertImage(QString filename,bool forceSize = false); void saveImage(QString filename); void enlargeDisplay(); void reduceDisplay(); void setScale(int scale); void paintEvent(QPaintEvent *); void mousePressEvent ( QMouseEvent * event ); void currPositionMove(int shiftX,int shiftY); void ensureCurrPos(); int getScaleValue(); bool isModified(); int getHeight(); int getWidth(); void readAscDot(unsigned int asc, char *dot); void readZhDot(unsigned int ingb, char *dot); int inputTxtDot(QString txt,int *var); int inputRamDot(QString txt,unsigned char *pMap, vars_t *p_var); int charDotMap( char *dot,bool english ); int varDotMap(char *dot,int *var); int picDelOneChar(); int picDelNextChar(); t_charPara charPara; t_draw drawPara; int picSetHome(); int picSetEnd(); int getVarNum(); int readVar(SysPara *sysPara, unsigned char alt2); void getPrintDat(unsigned char *dat,unsigned char alt2,SysPara *sysPara); void getCharRamData(SysPara *sysPara); int resizePicRect(bool alt2); void movePicView(); void bindSysPara(SysPara *sysPara); int altPrint; int startRow; int startCol; int heightPoint; int widthPoint; int scale; int currXpos; int currYpos; int endRow; int endCol; bool zkEditEn; bool isInput ; bool pEditMode; void zkEditNow(); void zkEditSave(); void disp(); QString currentEditTxt; int resizePicWidth(bool rowEn); int getNextPos(int x, int n); int getLineEnd(int x); int getUpLine(int x); int getDownLine(int x); int getPrePos(int x, int n); int getBlandPos(int x, int n); int SiteStart(int x); void moveDots(int x1, int x2, int y1, int h, int w); int getFontHeight(int x, int y); void VarGapSet(int x, int h); int VarGetWidth(int x,int y,unsigned char *c); int getLineHeight(int x, int y); int getInserEnable(int x, int y, int w, int h); void delDots(int x1, int x2, int y1, int h); int isVar(int x, int y); int getPicRealHeight(); int getUpLineStart(int x, int y); int isCanDelete(int x, int y); void readPng(int x, int y, int w, int h); void insertImage1(QString filename, bool forceSize); void saveImage1(QString filename); public slots: void cursorFlash(); // 光标闪烁 Q_SIGNALS: void picWidgetModify(); void ShowKeybord( ); void rowColChanged(QString); void currXYChanged(QString); void ChangeFont(int cc); private: unsigned char pointMap[MAX_PIC_WIDGET_HEIGHT * (MAX_PIC_WIDGET_WIDTH)]; bool modified; int varNum; t_line line; int linePara[MAXLINE]; int lineNum; int lineMaxNum; //SysPara *sysPara1; void setModified(bool m); void saveZhDot(); char getZkPic(char *dat); int charInsert(int w,bool txtMode); int isBlankCol(); unsigned long zkOffset; unsigned char zkReadNum; unsigned int zkIncode; QFile *pzkEditFile; QString txt; /* 字库文件*/ QFile zkAsc; char cal_currHeightEn; // char currMode; // ddddd QFile zkHz05; QFile zkHz07; QFile zkHz09; QFile zkHz12; QFile zkHz16; QFile zkHz24; QFile zkHz16H; QFile zkHz24H; //QFile zkHz32; QFile unitogb; }; #endif /* PICWIDGET_H_ */