HWND CreatHScroll(int Left,int Top,int Right,Function *HScrollProcedure, HWND FatherWindow) { Windows TobeCreatWindow; HWND MidWin; memset(&TobeCreatWindow,0,sizeof(TobeCreatWindow)); TobeCreatWindow.Left=Left; TobeCreatWindow.Top=Top; TobeCreatWindow.Right=Right; TobeCreatWindow.Bottom=Top+SYSSCROLLWIDTH+2; TobeCreatWindow.Procedure=(Function *)WindowDefaultProcedure; TobeCreatWindow.WindowStyle=WindowSetIsHScroll(); MidWin=WindowAppend(&TobeCreatWindow,FatherWindow); // left button CreatButton(0,0,SYSSCROLLWIDTH,SYSSCROLLWIDTH,WindowSetIsLeftScroll(), WINDOWLEFTSCROLL,"",NULL,MidWin); // right button CreatButton(WindowGetWidth(MidWin)-SYSSCROLLWIDTH,0, WindowGetWidth(MidWin),SYSSCROLLWIDTH, WindowSetIsRightScroll(),WINDOWRIGHTSCROLL,"",NULL,MidWin); // scroll button CreatButton(SYSSCROLLWIDTH,0,2*SYSSCROLLWIDTH,SYSSCROLLWIDTH, WindowSetIsHHScroll(),WINDOWHHSCROLL,"",HScrollProcedure, MidWin); return(MidWin); }
HWND CreatVScroll(int Left,int Top,int Bottom,Function *VScrollProcedure, HWND FatherWindow) { Windows TobeCreatWindow; HWND MidWin; memset(&TobeCreatWindow,0,sizeof(TobeCreatWindow)); TobeCreatWindow.Left=Left; TobeCreatWindow.Top=Top; TobeCreatWindow.Right=Left+SYSSCROLLWIDTH+1; TobeCreatWindow.Bottom=Bottom; TobeCreatWindow.Procedure=(Function *)WindowDefaultProcedure; TobeCreatWindow.WindowStyle=WindowSetIsVScroll(); MidWin=WindowAppend(&TobeCreatWindow,FatherWindow); // up button CreatButton(0,0,SYSSCROLLWIDTH,SYSSCROLLWIDTH, WindowSetIsUpScroll(),WINDOWUPSCROLL,"",NULL,MidWin); // down button CreatButton(0,WindowGetHeight(MidWin)-SYSSCROLLWIDTH-2, SYSSCROLLWIDTH,WindowGetHeight(MidWin)-2, WindowSetIsDownScroll(),WINDOWDOWNSCROLL,"",NULL,MidWin); // scroll button CreatButton(0,SYSSCROLLWIDTH,SYSSCROLLWIDTH,2*SYSSCROLLWIDTH, WindowSetIsVVScroll(),WINDOWVVSCROLL,"",VScrollProcedure, MidWin); return(MidWin); }
static int CreatSubDialogBox(Dialogs *DialogItems,HWND Window, HWND *DefaultActiveWindow,int *CurrentDefaultClass) { // The topest call must let // DefaultActiveWindow = 0 ( for default ) // and CurrentDefaultClass = 0 int j,TotalItem; HWND MidWindow; TotalItem=1; switch (DialogItems[0].ItemType) { case OKBUTTON: (DialogItems[0]).ItemUserData=DIALOGBOXOK; if (DialogItems[0].ItemTitle[0]==0) strcpy(DialogItems[0].ItemTitle,"È·¶¨"); goto creat_win; case CANCELBUTTON: (DialogItems[0]).ItemUserData=DIALOGBOXCANCEL; if (DialogItems[0].ItemTitle[0]==0) strcpy(DialogItems[0].ItemTitle,"È¡Ïû"); case USERBUTTONITEM: creat_win: MidWindow=CreatButton((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemBottom, WindowSetIsUserButton(), (DialogItems[0]).ItemUserData, (DialogItems[0]).ItemTitle, (DialogItems[0]).ItemProcedure, Window); if (*CurrentDefaultClass<1&&DialogItems[0].ItemType==OKBUTTON) { *DefaultActiveWindow=MidWindow; *CurrentDefaultClass=1; } break; case COMBOXITEM: CreatCombo((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemBottom, (DialogItems[0]).ItemProcedure, Window); break; case SINGLELINEEDITORITEM: MidWindow=CreatSingleLineEditor((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemBottom, (DialogItems[0]).ItemProcedure, Window); if (*CurrentDefaultClass<3) { *DefaultActiveWindow=MidWindow; *CurrentDefaultClass=3; } break; case LISTBOXITEM: MidWindow=CreatListBox((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemBottom, (DialogItems[0]).ItemProcedure, Window); if (*CurrentDefaultClass<2) { *DefaultActiveWindow=MidWindow; *CurrentDefaultClass=2; } break; case SINGLESELECT: CreatRadioButton((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemUserData&0x00ff, (DialogItems[0]).ItemUserData&0x8000, (DialogItems[0]).ItemTitle, ((DialogItems[0]).ItemUserData&0x3f00)>>8, (DialogItems[0]).ItemProcedure, Window); break; case MULTISELECT: CreatFrameButton((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemUserData&0x00ff, (DialogItems[0]).ItemUserData&0x8000, (DialogItems[0]).ItemTitle, ((DialogItems[0]).ItemUserData&0x3f00)>>8, (DialogItems[0]).ItemProcedure, Window); break; case FRAMEITEM: { HWND FrameWindow; int i; FrameWindow=CreatFrameWindow((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemBottom, (DialogItems[0]).ItemTitle, (DialogItems[0]).ItemProcedure, Window); if(FrameWindow<0) return 10000; for (i=0,j=1;i<(DialogItems[0]).ItemTotal;i++) { j+=CreatSubDialogBox(&DialogItems[j], FrameWindow, DefaultActiveWindow,CurrentDefaultClass); } TotalItem+=j-1; } break; case STATICTEXTITEM: CreatStaticText((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemTitle, (DialogItems[0]).ItemProcedure, Window); break; case HSCROLLITEM: CreatHScroll((DialogItems[0]).ItemLeft, (DialogItems[0]).ItemTop, (DialogItems[0]).ItemRight, (DialogItems[0]).ItemProcedure, Window); break; } return(TotalItem); }
AdvancedCalwidget::AdvancedCalwidget(QWidget *parent):CalWidget(parent) { Button* SinButton=CreatButton("sin",SLOT(FunctionClicked())); Button* CosButton=CreatButton("cos",SLOT(FunctionClicked())); Button* TanButton=CreatButton("tan",SLOT(FunctionClicked())); Button* ArcsinButton=CreatButton("arcsin",SLOT(FunctionClicked())); Button* ArccosButton=CreatButton("arccos",SLOT(FunctionClicked())); Button* ArctanButton=CreatButton("arctan",SLOT(FunctionClicked())); Button* ExpButton=CreatButton("exp",SLOT(FunctionClicked())); Button* Log10Button=CreatButton("log10",SLOT(FunctionClicked())); Button* Log2Button=CreatButton("log2",SLOT(FunctionClicked())); Button* CeilButton=CreatButton("ceil",SLOT(FunctionClicked())); Button* FloorButton=CreatButton("floor",SLOT(FunctionClicked())); Button* AbsButton=CreatButton("abs",SLOT(FunctionClicked())); Button* FacButton=CreatButton("fac",SLOT(FunctionClicked())); Button* IButton=CreatButton("i",SLOT(iClicked())); Button* FractionButton=CreatButton("x|y",SLOT(fractionClicked())); Button* AnswerButton=CreatButton("Ans",SLOT(AnsClicked())); Button* RandButton=CreatButton("rand",SLOT(RandClicked())); Button* EquationButton=CreatButton("x=?",SLOT(equationClicked())); Button* StatisticButton=CreatButton("∑x",SLOT(statisticClicked())); Button* PolyButton=CreatButton("ax+bx",SLOT(polyClicked())); //QLabel* label=new QLabel("\t函数功能键区\t"); //QFont font=label->font(); //font.setPointSize(font.pointSize()+2); //label->setFont(font); //label->setFrameShape(QFrame::StyledPanel); resultDisplay=new QLineEdit("0"); QFont font = resultDisplay->font(); font.setPointSize(font.pointSize() + 8); resultDisplay->setAlignment(Qt::AlignRight); resultDisplay->setReadOnly(true); resultDisplay->setFont(font); QGridLayout* rlayout=new QGridLayout; rlayout->addWidget(resultDisplay,0,0,1,4); rlayout->addWidget(SinButton,1,0); rlayout->addWidget(CosButton,1,1); rlayout->addWidget(TanButton,1,2); rlayout->addWidget(ArcsinButton,2,0); rlayout->addWidget(ArccosButton,2,1); rlayout->addWidget(ArctanButton,2,2); rlayout->addWidget(ExpButton,3,0); rlayout->addWidget(Log10Button,3,1); rlayout->addWidget(Log2Button,3,2); rlayout->addWidget(CeilButton,4,0); rlayout->addWidget(FloorButton,4,1); rlayout->addWidget(AbsButton,4,2); rlayout->addWidget(AnswerButton,5,0); rlayout->addWidget(FacButton,5,1); rlayout->addWidget(IButton,5,2); rlayout->addWidget(FractionButton,5,3); rlayout->addWidget(RandButton,3,3); rlayout->addWidget(EquationButton,1,3); rlayout->addWidget(StatisticButton,2,3); rlayout->addWidget(PolyButton,4,3); alayout=new QHBoxLayout; QFrame* line=new QFrame(this); line->setFrameShape(QFrame::VLine); line->setFrameShadow(QFrame::Sunken); //seperator->setFrameShape(QFrame::VLine); alayout->addLayout(layout);; //alayout->addSpacing(10); alayout->addWidget(line); alayout->addLayout(rlayout); }
//#include "memory.h" CalWidget::CalWidget(QWidget *parent):QWidget(parent) { floatNumber=6; //isRound=false; formatState=FORMAT_MIXED; EqualState=true; display=new QLineEdit("0"); //display->setMaxLength(15); Button* BspaceButton=CreatButton(tr("退格"),SLOT(BspaceClicked())); Button* ClearButton=CreatButton(tr("清除"),SLOT(ClearClicked())); Button* CAllButton=CreatButton(tr("清除全部"),SLOT(CAllClicked())); Button* AddButton=CreatButton(tr("+"),SLOT(OrdinaryClicked())); Button* SubButton=CreatButton(tr("-"),SLOT(OrdinaryClicked())); Button* MulButton=CreatButton(tr("*"),SLOT(OrdinaryClicked())); Button* DivButton=CreatButton(tr("/"),SLOT(OrdinaryClicked())); Button* PowButton=CreatButton(tr("^"),SLOT(OrdinaryClicked())); Button* SqrtButton=CreatButton(tr("sqrt"),SLOT(FunctionClicked())); Button* LnButton=CreatButton(tr("ln"),SLOT(FunctionClicked())); Button* EqualButton=CreatButton(tr("="),SLOT(EqualClicked())); Button* PaiButton=CreatButton(tr("Pai"),SLOT(PaiClicked())); Button* PointButton=CreatButton(tr("."),SLOT(PointClicked())); //Button* LBBracketButton=CreatButton(tr("{"),SLOT(OrdinaryClicked())); //Button* RBBracketButton=CreatButton(tr("}"),SLOT(OrdinaryClicked())); Button* UpButton=CreatButton("↑",SLOT(upClicked())); Button* DownButton=CreatButton("↓",SLOT(downClicked())); Button* LBracketButton=CreatButton(tr("("),SLOT(OrdinaryClicked())); Button* RBracketButton=CreatButton(tr(")"),SLOT(OrdinaryClicked())); Button* ModButton=CreatButton(tr("%"),SLOT(OrdinaryClicked())); for(int i=0;i<10;++i) { DigitButton[i]=CreatButton(QString::number(i),SLOT(OrdinaryClicked())); } layout=new QGridLayout; layout->setSizeConstraint(QLayout::SetFixedSize); layout->addWidget(display,0,0,1,6); layout->addWidget(BspaceButton,1,0,1,2); layout->addWidget(ClearButton, 1, 2, 1, 2); layout->addWidget(CAllButton, 1, 5, 1, 1); for(int i=1;i<10;++i) { int r=4-(i-1)/3; int c=(i-1)%3; layout->addWidget(DigitButton[i],r,c); } layout->addWidget(AddButton,5,3); layout->addWidget(SubButton,4,3); layout->addWidget(MulButton,3,3); layout->addWidget(DivButton,2,3); layout->addWidget(SqrtButton,2,5); layout->addWidget(LnButton,3,5); layout->addWidget(PowButton,4,5); layout->addWidget(PaiButton,5,5); layout->addWidget(DigitButton[0],5,0); layout->addWidget(EqualButton,5,2); layout->addWidget(PointButton,5,1); //layout->addWidget(LBBracketButton,1,4); //layout->addWidget(RBBracketButton,2,4); layout->addWidget(UpButton,1,4); layout->addWidget(DownButton,2,4); layout->addWidget(LBracketButton,3,4); layout->addWidget(RBracketButton,4,4); layout->addWidget(ModButton,5,4); }