📄 kdu_show.cpp
字号:
// Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CPropertyHelpDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL// Implementationprivate: CStatic *get_static() { return (CStatic *) GetDlgItem(IDC_MESSAGE); }private: char *string; kdu_coords placement;protected: // Generated message map functions //{{AFX_MSG(CPropertyHelpDlg) virtual BOOL OnInitDialog(); //}}AFX_MSG DECLARE_MESSAGE_MAP()};/******************************************************************************//* CPropertyHelpDlg::CPropertyHelpDlg *//******************************************************************************/CPropertyHelpDlg::CPropertyHelpDlg(char *string, kdu_coords placement, CWnd* pParent) : CDialog(CPropertyHelpDlg::IDD, pParent){ this->string = string; this->placement = placement;}/******************************************************************************//* CPropertyHelpDlg::OnInitDialog *//******************************************************************************/BOOL CPropertyHelpDlg::OnInitDialog() { CDialog::OnInitDialog(); while (*string == '\n') string++; // Skip leading empty lines, if any get_static()->SetWindowText(string); // Move dialog window to desired position SetWindowPos(NULL,placement.x,placement.y,0,0, SWP_NOZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); // Find the height of the displayed text int text_height = 0; SIZE text_size; CDC *dc = get_static()->GetDC(); while (*string != '\0') { char *sp = strchr(string,'\n'); if (sp == NULL) sp = string + strlen(string); if (string != sp) text_size = dc->GetTextExtent(string,sp-string); text_height += text_size.cy; string = (*sp != '\0')?sp+1:sp; } get_static()->ReleaseDC(dc); // Resize windows to fit the text height WINDOWPLACEMENT dialog_placement, static_placement; GetWindowPlacement(&dialog_placement); get_static()->GetWindowPlacement(&static_placement); int dialog_width = dialog_placement.rcNormalPosition.right - dialog_placement.rcNormalPosition.left; int static_width = static_placement.rcNormalPosition.right - static_placement.rcNormalPosition.left; int dialog_height = dialog_placement.rcNormalPosition.bottom - dialog_placement.rcNormalPosition.top; int static_height = static_placement.rcNormalPosition.bottom - static_placement.rcNormalPosition.top; get_static()->SetWindowPos(NULL,0,0,static_width,text_height+8, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); SetWindowPos(NULL,0,0,dialog_width,text_height+8+dialog_height-static_height, SWP_NOZORDER | SWP_NOMOVE | SWP_SHOWWINDOW); return TRUE; // return TRUE unless you set the focus to a control}/******************************************************************************//* CPropertyHelpDlg::DoDataExchange *//******************************************************************************/void CPropertyHelpDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPropertyHelpDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(CPropertyHelpDlg, CDialog) //{{AFX_MSG_MAP(CPropertyHelpDlg) //}}AFX_MSG_MAPEND_MESSAGE_MAP()/* ========================================================================== *//* CPropertiesDlg *//* ========================================================================== */class CPropertiesDlg : public CDialog{// Constructionpublic: CPropertiesDlg(kdu_codestream codestream, std::ostrstream *string_buf, CWnd* pParent=NULL);// Dialog Data //{{AFX_DATA(CPropertiesDlg) enum { IDD = IDD_PROPERTIESBOX }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA// Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CPropertiesDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL// Implementationprotected: // Generated message map functions //{{AFX_MSG(CPropertiesDlg) afx_msg void OnDblclkPropertiesList(); //}}AFX_MSG DECLARE_MESSAGE_MAP()// ----------------------------------------------------------------------------protected: BOOL OnInitDialog();private: CListBox *get_list() { return (CListBox *) GetDlgItem(IDC_PROPERTIES_LIST); }private: kdu_codestream codestream; std::ostrstream *string_buf;};BEGIN_MESSAGE_MAP(CPropertiesDlg, CDialog) //{{AFX_MSG_MAP(CPropertiesDlg) ON_LBN_DBLCLK(IDC_PROPERTIES_LIST, OnDblclkPropertiesList) //}}AFX_MSG_MAPEND_MESSAGE_MAP()/******************************************************************************//* CPropertiesDlg::CPropertiesDlg *//******************************************************************************/CPropertiesDlg::CPropertiesDlg(kdu_codestream codestream, std::ostrstream *string_buf, CWnd* pParent) : CDialog(CPropertiesDlg::IDD, pParent){ //{{AFX_DATA_INIT(CPropertiesDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT this->codestream = codestream; this->string_buf = string_buf;}/******************************************************************************//* CPropertiesDlg::DoDataExchange *//******************************************************************************/void CPropertiesDlg::DoDataExchange(CDataExchange* pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPropertiesDlg) // NOTE: the ClassWizard will add DDX and DDV calls here //}}AFX_DATA_MAP}/******************************************************************************//* CPropertiesDlg::OnInitDialog *//******************************************************************************/BOOL CPropertiesDlg::OnInitDialog(){ CDialog::OnInitDialog(); char *string = string_buf->str(); int count = string_buf->pcount(); int max_width = 0;; char tbuf[256]; while (count > 0) { char *tp = tbuf; SIZE text_size; for (; (count > 0) && (*string != '\n'); count--, string++) if ((tp-tbuf) < 255) *(tp++) = *string; *tp = '\0'; get_list()->AddString(tbuf); CDC *dc = get_list()->GetDC(); GetTextExtentPoint32(dc->m_hDC,tbuf,tp-tbuf,&text_size); get_list()->ReleaseDC(dc); if (text_size.cx > max_width) max_width = text_size.cx; string++; count--; // skip over the newline character. } string_buf->rdbuf()->freeze(0); get_list()->SetCurSel(-1); get_list()->SetHorizontalExtent(max_width+10); return TRUE;}/******************************************************************************//* CPropertiesDlg::OnDblclkPropertiesList *//******************************************************************************/void CPropertiesDlg::OnDblclkPropertiesList() { int selection = get_list()->GetCurSel(); int length = get_list()->GetTextLen(selection); char *string = new char[length+1]; get_list()->GetText(selection,string); const char *attribute_id; kdu_params *obj = codestream.access_siz()->find_string(string,attribute_id); delete[] string; if (obj != NULL) { std::ostrstream string_buf; kdu_pretty_buf pretty(&string_buf,60); std::ostream redirected(&pretty); obj->describe_string(attribute_id,redirected,true); redirected.flush(); char *buf = string_buf.str(); int buf_len = string_buf.pcount(); if (buf_len > 0) buf[buf_len-1] = '\0'; POINT point; GetCursorPos(&point); CPropertyHelpDlg help(buf,kdu_coords(point.x,point.y),this); help.DoModal(); string_buf.rdbuf()->freeze(0); }}/* ========================================================================== *//* CKdu_showApp Class Implementation *//* ========================================================================== */BEGIN_MESSAGE_MAP(CKdu_showApp, CWinApp) //{{AFX_MSG_MAP(CKdu_showApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_FILE_CLOSE, OnFileClose) ON_UPDATE_COMMAND_UI(ID_FILE_CLOSE, OnUpdateFileClose) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) ON_COMMAND(ID_VIEW_HFLIP, OnViewHflip) ON_UPDATE_COMMAND_UI(ID_VIEW_HFLIP, OnUpdateViewHflip) ON_COMMAND(ID_VIEW_VFLIP, OnViewVflip) ON_UPDATE_COMMAND_UI(ID_VIEW_VFLIP, OnUpdateViewVflip) ON_COMMAND(ID_VIEW_ROTATE, OnViewRotate) ON_UPDATE_COMMAND_UI(ID_VIEW_ROTATE, OnUpdateViewRotate) ON_COMMAND(ID_VIEW_COUNTER_ROTATE, OnViewCounterRotate) ON_UPDATE_COMMAND_UI(ID_VIEW_COUNTER_ROTATE, OnUpdateViewCounterRotate) ON_COMMAND(ID_VIEW_ZOOM_OUT, OnViewZoomOut) ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_OUT, OnUpdateViewZoomOut) ON_COMMAND(ID_VIEW_ZOOM_IN, OnViewZoomIn) ON_UPDATE_COMMAND_UI(ID_VIEW_ZOOM_IN, OnUpdateViewZoomIn) ON_COMMAND(ID_VIEW_RESTORE, OnViewRestore) ON_UPDATE_COMMAND_UI(ID_VIEW_RESTORE, OnUpdateViewRestore) ON_COMMAND(ID_MODE_FAST, OnModeFast) ON_UPDATE_COMMAND_UI(ID_MODE_FAST, OnUpdateModeFast) ON_COMMAND(ID_MODE_FUSSY, OnModeFussy) ON_UPDATE_COMMAND_UI(ID_MODE_FUSSY, OnUpdateModeFussy) ON_COMMAND(ID_MODE_RESILIENT, OnModeResilient) ON_UPDATE_COMMAND_UI(ID_MODE_RESILIENT, OnUpdateModeResilient) ON_COMMAND(ID_VIEW_WIDEN, OnViewWiden) ON_UPDATE_COMMAND_UI(ID_VIEW_WIDEN, OnUpdateViewWiden) ON_COMMAND(ID_VIEW_SHRINK, OnViewShrink) ON_UPDATE_COMMAND_UI(ID_VIEW_SHRINK, OnUpdateViewShrink) ON_COMMAND(ID_FILE_PROPERTIES, OnFileProperties) ON_UPDATE_COMMAND_UI(ID_FILE_PROPERTIES, OnUpdateFileProperties) ON_COMMAND(ID_COMPONENT1, OnComponent1) ON_UPDATE_COMMAND_UI(ID_COMPONENT1, OnUpdateComponent1) ON_COMMAND(ID_COMPONENT2, OnComponent2) ON_UPDATE_COMMAND_UI(ID_COMPONENT2, OnUpdateComponent2) ON_COMMAND(ID_COMPONENT3, OnComponent3) ON_UPDATE_COMMAND_UI(ID_COMPONENT3, OnUpdateComponent3) ON_COMMAND(ID_COMPONENT4, OnComponent4) ON_UPDATE_COMMAND_UI(ID_COMPONENT4, OnUpdateComponent4) ON_COMMAND(ID_MULTI_COMPONENT, OnMultiComponent) ON_UPDATE_COMMAND_UI(ID_MULTI_COMPONENT, OnUpdateMultiComponent) ON_COMMAND(ID_LAYERS_LESS, OnLayersLess) ON_UPDATE_COMMAND_UI(ID_LAYERS_LESS, OnUpdateLayersLess) ON_COMMAND(ID_LAYERS_MORE, OnLayersMore) ON_UPDATE_COMMAND_UI(ID_LAYERS_MORE, OnUpdateLayersMore) ON_COMMAND(ID_MODE_RESILIENT_SOP, OnModeResilientSop) ON_UPDATE_COMMAND_UI(ID_MODE_RESILIENT_SOP, OnUpdateModeResilientSop) //}}AFX_MSG_MAPEND_MESSAGE_MAP()/******************************************************************************//* CKdu_showApp::CKdu_showApp *//******************************************************************************/CKdu_showApp::CKdu_showApp(){ _CrtSetBreakAlloc(27); fast = true; fussy = resilient = resilient_sop = false; child = NULL; tiles_loaded = false; discard_levels = 0; max_discard_levels = -1; total_components = single_component = reference_component = 0; expansion = min_expansion = kdu_coords(0,0); image_dims.pos = image_dims.size = kdu_coords(0,0); view_dims = buffer_dims = valid_dims = image_dims; view_centre_known = false; buffer = NULL; buffer_extent = kdu_coords(0,0); in_idle = false; processing = false;}/******************************************************************************//* CKdu_showApp::~CKdu_showApp *//******************************************************************************/CKdu_showApp::~CKdu_showApp(){ if (codestream.exists()) codestream.destroy(); file_input.close(); jp2_input.close(); if (buffer != NULL) delete[] buffer;}/******************************************************************************//* CKdu_showApp::InitInstance *//******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -