内容へ移動
TG classes
-
KobaWiki@RCNP
トレース:
文書の表示
管理
最近の変更
サイトマップ
ログイン
検索
この文書は読取専用です。文書のソースを閲覧することは可能ですが、変更はできません。もし変更したい場合は管理者に連絡してください。
===== TG classes ===== ==== リンク ==== * [[https://root.cern.ch/root/html602/index.html|ROOT Reference Guide]] >> [[https://root.cern.ch/root/html602/GUI_Index.html|GUI]] >> [[https://root.cern.ch/root/html602/GUI_GUI_Index.html|GUI]] * [[https://root.cern.ch/root/htmldoc/guides/users-guide/WritingGUI.html|Writing GUI]] ==== TGLayoutHints ==== * [[https://root.cern.ch/root/html602/TGLayoutHints.html|TGLayoutHints]](ULong_t hints, Int_t padleft, Int_t padright, Int_t padtop, Int_t padbottom) の padleft, padright, padtop, padbottom は左右上下の padding を px 単位で与える。hints には、配置したい場所を指定する。[[https://root.cern.ch/root/html602/src/TGLayoutManager.h.html#33|TGLayoutManager.h]] で定義される<code> enum ELayoutHints { kLHintsNoHints = 0, kLHintsLeft = BIT(0), kLHintsCenterX = BIT(1), kLHintsRight = BIT(2), kLHintsTop = BIT(3), kLHintsCenterY = BIT(4), kLHintsBottom = BIT(5), kLHintsExpandX = BIT(6), kLHintsExpandY = BIT(7), kLHintsNormal = (kLHintsLeft | kLHintsTop) // bits 8-11 used by ETableLayoutHints }; </code> から指定する。kLHintsLeft | kLHintsTop | kLHintsExpandY というように、or ビット演算子 | を用いて複数指定できる。BIT は ==== Widget の配置 ==== * widget を縦から配置していく分には、MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h) クラス内で <code> fLbl1 = new TGLabel(this, "Label1"); AddFrame(fLbl1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4)); fLbl2 = new TGLabel(this, "Label2"); AddFrame(fLbl2, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4)); </code> のように書いていけば良い。横に widget を横に並べるには、<code> TGHorizontalFrame *hframe = new TGHorizontalFrame(this, 300, 20, kFixedWidth); fLbl1 = new TGLabel(hframe, "Label1"); hframe->AddFrame(fLbl1, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4)); fLbl2 = new TGLabel(hframe, "Label2"); hframe->AddFrame(fLbl2, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4)); AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 10, 10, 2, 2)); </code> のように書く。TGLabel を new するとき、 this ではなく hframe とするので注意。 ==== TGFileBrowser ==== * void TGFileBrowser::DoubleClicked(TGListTreeItem *item, Int_t /*btn*/) {} の注意点 * TGFileBrowser の TF2 などのヒストグラム (名前を h4 とする) の TGListTreeItem をダブルクリックしたとき、以下のエラーが出る時がある。<code> Error: Symbol h4 is not defined in current scope (tmpfile):1: Error: Failed to evaluate h4->Draw("colz") *** Interpreter error recovered *** </code> これは、TGFileBrowser::DoubleClicked の問題と言えるかもしれないが、.root.mimes を <code> [root/th2] pattern = TH2[CSFDI] icon = h2_s.xpm h2_t.xpm action = ->Draw("colz") </code> と編集し、さらに現在いるディレクトリからヒストグラム h4 が見えない (すなわち、h4 が違う TFile や TDirectoryFile にいて、現在のディレクトリで gApplication->ProcessLine(act.Data()) (ただし、act.Data() = "h4->Draw(\"colz\");") を実行しても h4 を参照できない) ときに生じるエラーである。(TH2 の action を .root.mimes から gClient->GetMimeTypeList()->GetAction(obj->IsA()->GetName(), action) という関数で取得し、"->Draw()" という文字列が action 内に含まれるかを act.Contains("->Draw()") という関数で判別している。) 解決方法としては、.root.mimes を編集することを諦め、<code> [root/th2] pattern = TH2[CSFDI] icon = h2_s.xpm h2_t.xpm action = ->Draw() </code> というようにデフォルトに戻すか、TGListTreeItem をクリックした際に発生する DoubleClick のシグナルをフックし、current directory (gDirectory) を変更し h4 を見えるようにする。必要であれば、TGFileBrowser.cxx を書き換えても良い。もしこれがただのバグであれば、ROOT 開発チームに要望を出す。
文書の表示
以前のリビジョン
メディアマネージャー
文書の先頭へ