Программирование с gtkmm (Главы 6-7)

Murray Cumming, Bernhard Rieder, Jonathon Jongsma, Jason M’Sadoques, Ole Laursen, Gene Ruebsamen, Cedric Gustin, Marko Anastasov, and Alan Ott, “Programming with gtkmm (Chapters 6-7)”, public translation into Russian from English More about this translation.

See also 100 similar translations

Translate into another language.

Participants

JBL3561 points
avlakan2019 points
kolen1461 points
And others...
Join Translated.by to translate! If you already have a Translated.by account, please sign in.
If you do not want to register an account, you can sign in with OpenID.
Pages: ← previous Ctrl next next untranslated

Programming with gtkmm (Chapters 6-7)

Программирование с gtkmm (Главы 6-7)

History of edits (Latest: JBL 3 years, 3 months ago) §

Chapter 6. Miscellaneous Widgets

Глава 6. Разные виджеты

History of edits (Latest: JBL 3 years, 3 months ago) §

6.1. Label
Labels are the main method of placing non-editable text in windows, for instance to place a title next to a
Entry widget. You can specify the text in the constructor, or with the set_text() method.

6.1. Ярлык (Label)
Ярлыки - это основной метод размещения не редактируемого текста в окнах, например, разместить текст рядом с виджетом ввода. Вы можете задать текст в конструкторе, или методом set_text().

History of edits (Latest: JBL 3 years, 3 months ago) §

— Кстати, Label - это скорее "метка", нежели "ярлык", особенно в данном контексте. netrino

— Может быть так и перевести - "нередактируемое поле", "нередактируемая область"? space_indus

— Ну это уж слишком, по-моему ) netrino

— Просто "Ярлык" слух как то дико в этом контексте звучит... space_indus

The width of the label will be adjusted automatically. You can produce multi-line labels by putting line
breaks ("\n") in the label string.

Ширина ярлыка будет откоректированна автоматически. Можно использовать многострочные ярлыки, помещая в конец каждой строки знак перевода строки '\n'.

History of edits (Latest: JBL 3 years, 3 months ago) §

The label text can be justified using the set_justify() method. The widget is also capable of
word-wrapping - this can be activated with set_line_wrap().

Текст ярлыка может быть выровнен методом set_justify() .
Виджет также способен перносить слова - это можно активировать методом set_line_wrap().

History of edits (Latest: lynx 1 year, 10 months ago) §

TODO: gtkmm2: markup.
Reference (../../reference/html/classGtk_1_1Label.html)

TODO: gtkmm2: разметка.
Подробнее (../../reference/html/classGtk_1_1Label.html)

History of edits (Latest: lynx 1 year, 10 months ago) §

6.1.1. Example
Below is a short example to illustrate these functions. This example makes use of the Frame widget to
better demonstrate the label styles. (The Frame widget is explained in the Frame section.)

Source Code (../../../examples/book/label)

6.1.1. Пример
Ниже приведен короткий пример, иллюстрирующий эти функции. Этот пример использует виджет Frame для лучшего отображения стилей ярлыка. (Виджет Frame описывается в разделе Frame).

Исходный код (../../../examples/book/label)

History of edits (Latest: JBL 3 years ago) §

File: examplewindow.h
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H
#include <gtkmm.h>

Файл: examplewindow.h
#ifndef GTKMM_EXAMPLEWINDOW_H
#define GTKMM_EXAMPLEWINDOW_H
#include <gtkmm.h>

History of edits (Latest: JBL 3 years, 3 months ago) §

class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Child widgets:
Gtk::HBox m_HBox;
Gtk::VBox m_VBox, m_VBox2;
Gtk::Frame m_Frame_Normal, m_Frame_Multi, m_Frame_Left, m_Frame_Right,
m_Frame_LineWrapped, m_Frame_FilledWrapped, m_Frame_Underlined;
Gtk::Label m_Label_Normal, m_Label_Multi, m_Label_Left, m_Label_Right,
m_Label_LineWrapped, m_Label_FilledWrapped, m_Label_Underlined;
};
#endif //GTKMM_EXAMPLEWINDOW_H

class ExampleWindow : public Gtk::Window
{
public:
ExampleWindow();
virtual ~ExampleWindow();
protected:
//Дочернии виджеты:
Gtk::HBox m_HBox;
Gtk::VBox m_VBox, m_VBox2;
Gtk::Frame m_Frame_Normal, m_Frame_Multi, m_Frame_Left, m_Frame_Right,
m_Frame_LineWrapped, m_Frame_FilledWrapped, m_Frame_Underlined;
Gtk::Label m_Label_Normal, m_Label_Multi, m_Label_Left, m_Label_Right,
m_Label_LineWrapped, m_Label_FilledWrapped, m_Label_Underlined;
};
#endif //GTKMM_EXAMPLEWINDOW_H

History of edits (Latest: JBL 3 years, 3 months ago) §

File: main.cc
#include <gtkmm/main.h>
#include "examplewindow.h"

Файл: main.cc
#include <gtkmm/main.h>
#include "examplewindow.h"

History of edits (Latest: JBL 3 years, 3 months ago) §

int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
//Shows the window and returns when it is closed.
Gtk::Main::run(window);
return 0;
}

int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
//Показывает окно и возвращается когда закроется окно.
Gtk::Main::run(window);
return 0;
}

History of edits (Latest: JBL 3 years, 3 months ago) §

File: examplewindow.cc

Файл: examplewindow.cc

History of edits (Latest: JBL 3 years, 3 months ago) §

#include "examplewindow.h"
#include <iostream>

#include "examplewindow.h"
#include <iostream>

History of edits (Latest: JBL 3 years, 3 months ago) §

ExampleWindow::ExampleWindow()
:
m_HBox(false, 5),
m_VBox(false, 5),
m_Frame_Normal("Normal Label"),
m_Frame_Multi("Multi-line Label"),
m_Frame_Left("Left Justified Label"),
m_Frame_Right("Right Justified Label"),
m_Frame_LineWrapped("Line wrapped label"),
m_Frame_FilledWrapped("Filled, wrapped label"),
m_Frame_Underlined("Underlined label"),
m_Label_Normal("_This is a Normal label", true),
m_Label_Multi("This is a Multi-line label.\nSecond line\nThird line"),
m_Label_Left("This is a Left-Justified\nMulti-line label.\nThird line"),
m_Label_Right("This is a Right-Justified\n"
"Multi-line label.\nFourth line, (j/k)"),
m_Label_Underlined("This label is underlined!\n"
"This one is underlined in quite a funky fashion")
{
set_title("Label");
set_border_width(5);
add(m_HBox);

ExampleWindow::ExampleWindow()
:
m_HBox(false, 5),
m_VBox(false, 5),
m_Frame_Normal("Normal Label"),
m_Frame_Multi("Multi-line Label"),
m_Frame_Left("Left Justified Label"),
m_Frame_Right("Right Justified Label"),
m_Frame_LineWrapped("Line wrapped label"),
m_Frame_FilledWrapped("Filled, wrapped label"),
m_Frame_Underlined("Underlined label"),
m_Label_Normal("_This is a Normal label", true),
m_Label_Multi("This is a Multi-line label.\nSecond line\nThird line"),
m_Label_Left("This is a Left-Justified\nMulti-line label.\nThird line"),
m_Label_Right("This is a Right-Justified\n"
"Multi-line label.\nFourth line, (j/k)"),
m_Label_Underlined("This label is underlined!\n"
"This one is underlined in quite a funky fashion")
{
set_title("Label");
set_border_width(5);
add(m_HBox);

History of edits (Latest: kolen 3 years, 3 months ago) §
Pages: ← previous Ctrl next next untranslated

© Copyright © 2002-2006 Murray Cumming We very much appreciate any reports of inaccuracies or other errors in this document. Contributions are also most welcome. Post your suggestions, critiques or addenda to the gtkmm mailing list (mailto:gtkmm-list@gnome.. License: ermission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and